Validate JSON

Check if a string is valid JSON.

Code

General
try { JSON.parse(str); true; } catch { false; }

Parameters

The string to validate as JSON

Browser·fetch() may be limited by CORS

More JavaScript Snippets