How to use Validate JSON

  1. Paste your JSON into the Input JSON editor, or click Select files to load it from a file.
  2. Read the Validation Result box. It shows Valid JSON with a check mark, or a cross mark followed by the error message.
  3. Fix the reported problem in the editor; the input is checked again after every change.
  4. To try sample input, click one of the example cards below the tool to load it into the editor.

Examples

Valid object

Input: {"name": "John", "age": 30, "city": "New York"}. Result: Valid JSON.

Trailing comma

Input: {"a":1,}. Result: an Invalid JSON message saying that a double-quoted property name was expected. The exact wording depends on the browser.

JSON Lines

Input: {"a":1} on the first line and {"b":[1,2]} on the second. Result: Valid JSON, because each non-blank line is valid JSON on its own.

Good to know

  • The whole input is first parsed with JavaScript's JSON.parse, so any single JSON value is valid, including a bare number such as 42. If that fails and the input has more than one non-blank line, each line is checked separately as JSON Lines.
  • When a multi-line document fails both checks, the error names the first line that is not valid JSON on its own. For pretty-printed objects and arrays that is usually line 1, not necessarily the line with the mistake.
  • Only syntax is checked. There is no JSON Schema validation and no check of field names or value types.
  • Error messages come from the browser's built-in JSON parser, so the wording can differ between browsers.
  • The input editor is the Monaco code editor. The page downloads it from cdn.jsdelivr.net when the editor loads.

Frequently asked questions

Does it accept JSON Lines or NDJSON?

Yes. If the input is not one JSON document but every non-blank line parses as JSON, the result is Valid JSON. Blank lines are ignored.

Why does the error point to line 1 when the mistake is further down?

A multi-line input that is not valid JSON is re-checked line by line as JSON Lines. The error then names the first line that is not a complete JSON value. For a formatted object, that is the opening brace on line 1. With single-line input, you get the parser's own message instead.

Are trailing commas or comments allowed?

No. The input is parsed with standard JSON.parse, which rejects trailing commas, unquoted property names and comments.

More JSON Tools