How to Validate JSON Online (Free Tool + Common Errors)

How to Validate JSON Online: A Complete Guide for Developers

A single misplaced comma in a 10,000-line configuration file can take down an entire production API at 2 AM. This guide covers the only reliable methods to validate JSON syntax, pinpoint error locations, parse large files, and verify that JSON conforms to a schema — all from a browser, no installation required. The four-step workflow below handles raw JSON, JSON-with-comments, NDJSON (newline-delimited), and JSON Schema validation with equal precision.

Table of Contents

  1. What JSON Validation Actually Checks
  2. JSON vs JSON5 vs NDJSON: Three Formats You May Hit
  3. Step-by-Step: Validate Raw JSON in a Browser
  4. Reading the Error: Line and Column Where It Broke
  5. Common JSON Errors and How to Fix Them
  6. Validating Against a JSON Schema
  7. Validating Large Files (Over 50 MB)
  8. Why Validation Tools Disagree (and Which to Trust)

What JSON Validation Actually Checks {#what-it-is}

JSON (JavaScript Object Notation, RFC 8259, ECMA-404) is a strict text format. Every valid JSON document is a sequence of well-formed Unicode characters organized into exactly six structural tokens: object { }, array [ ], string "...", number, boolean (true/false), and null. Anything outside that grammar is invalid. The official grammar is 19 production rules; a parser that implemented them faithfully accepts every RFC 8259-compliant string and rejects everything else.

A validator asks three questions:

  1. Syntactic: is each character in a legal position? (Quotes balanced? Brackets closed? Comma between elements?)
  2. Structural: are tokens arranged in legal nesting? (Array inside object inside array inside object?)
  3. Semantic (optional, with JSON Schema): do the values match an expected type, range, or pattern? (Is "age" a number between 0 and 150? Is "email" a valid RFC 5322 address?)

The mytoolslist /tools/json-validator answers questions 1 and 2. Custom JSON Schema validation is available via /tools/json-schema-validator for question 3.

JSON vs JSON5 vs NDJSON: Three Formats You May Hit {#formats}

The JSON spec is famously strict, but the developer community has produced two practical extensions you may encounter:

  • JSON5 (proposed by JSON inventor Douglas Crockford's successors) — allows comments (// and /* */), trailing commas, unquoted object keys, single-quoted strings, and hex numbers. Used in some configuration files (VS Code's settings, Node.js's package.json via json5, certain React Native configs).
  • NDJSON (Newline-Delimited JSON) — one JSON object per line, no outer [ ]. Standard streaming format used by ElasticSearch bulk APIs, Apache Spark logs, and most modern log aggregation. Each line is independently parseable.

Standard JSON validators reject JSON5 and reject NDJSON (the outer [ ] is missing). The mytoolslist validator can be set to lenient mode for JSON5 or NDJSON detection if needed.

Step-by-Step: Validate Raw JSON in a Browser {#step-by-step}

  1. Paste or upload your JSON file. Drag-and-drop into the mytoolslist /tools/json-validator text area or paste from clipboard. Files up to 50 MB parse without a server upload — the parser runs in your browser via WebAssembly.
  2. Read the result panel. A valid document shows a green checkmark with the document's size in bytes and number of top-level keys. An invalid document shows a red error with a line number and column reference.
  3. Click "Pretty print" or "Minify" to view formatted output (2-space indented, ISO 8601 dates untouched) or compact output (no whitespace between tokens).
  4. Copy the result back to your editor. Most developers paste the minified version into a .json file and use the pretty-printed version for debugging.

Reading the Error: Line and Column Where It Broke {#reading-errors}

Standard error messages from JSON.parse() (the JavaScript built-in) look like:

SyntaxError: Unexpected token } in JSON at position 234

The browser parsers used by mytoolslist return more informative errors:

Line 12, Column 8: Expected ',' or ']' but found '}' at token 234

Reading this: your JSON document has 12 lines; the parser was reading position 8 of line 12 (which means after the eighth character); it expected either a comma (continuing more elements in the array) or a closing bracket ] but found a closing brace }. Most likely you have [{...}, {...}] where the second } was placed immediately after the first without a comma between them. Fix: add a comma.

Common JSON Errors and How to Fix Them {#common-errors}

The eight most common validation failures:

  1. Trailing comma: { "a": 1, "b": 2, } — the trailing comma after "b": 2 is invalid. Fix: remove the trailing comma.
  2. Single quotes instead of double quotes: {'a': 1} — JSON syntax is strictly double-quoted. Fix: replace single quotes with double quotes (or use single quotes inside string values: {"a": '1'} is still wrong; the value '1' must be {"a": "1"}).
  3. Unquoted keys: { a: 1 } — keys must be quoted strings. Fix: {"a": 1}.
  4. Comments in JSON: { "a": 1, /* comment */ "b": 2 } — JSON has no comment syntax. Remove the comments or save as .jsonc and use a JSON5 parser.
  5. Trailing semicolon: { "a": 1 }; — the final ; is not in the grammar. Fix: remove the semicolon.
  6. Mixed newline characters: copy-paste from Windows with \r\n line endings works fine, but \r alone (old Mac) confuses some parsers. Normalize to \n first.
  7. NaN / Infinity / undefined: { "x": NaN } — these are JavaScript primitives, not valid JSON values. Use null or omit the field.
  8. Hex numbers / octal escapes: { "x": 0x1A } — JSON only supports decimal; use 26 instead. The same applies to octal 0755 — use 493.

Validating Against a JSON Schema {#schema-validation}

A JSON Schema (Draft 2020-12, the current standard from json-schema.org) is a JSON document describing the expected shape of another JSON document. Schemas check:

| Constraint | Example | |---|---| | Type | "type": "string" — the value must be a string | | Required | "required": ["name", "email"] — these keys must be present | | Pattern | "pattern": "^[^@]+@[^@]+$" — value matches regex | | Range | "minimum": 0, "maximum": 150 — number bounds | | Enum | "enum": ["draft", "published"] — value in allowed set | | Nested | recursive schemas validate nested objects/arrays |

Schemas are widely used: OpenAPI 3.0 defines API contracts as JSON Schema; GitHub Action workflow files; VS Code's package.json; Stripe's webhook payloads. Validating against a schema catches whole categories of bugs that syntax validation misses (e.g., a missing required field, a string where a number is expected).

Validating Large Files (Over 50 MB) {#large-files}

Browser-based parsers top out around 50 MB because they hold the entire document in memory as a JavaScript object. For larger files:

  1. Streaming parser: Node.js stream-json reads JSON incrementally — can handle multi-GB files; useful but trickier to write.
  2. Command-line jq: jq . hugefile.json validates and pretty-prints in one pass; very fast.
  3. Cloud bulk validation: AWS S3 + Lambda + JSON parsing for tens of GB.
  4. NDJSON conversion: if your file is actually NDJSON (one object per line), most streaming parsers handle it faster than full JSON.

For the browser-based mytoolslist validator, drag-and-drop 50–100 MB files work — anything much larger times out. For larger files, the right move is a CLI tool or a streaming library on the server.

Why Validation Tools Disagree (and Which to Trust) {#tool-disagreement}

Different JSON libraries sometimes agree on "syntactically valid" but disagree on edge cases:

  • Duplicate keys: { "a": 1, "a": 2 }. The RFC says duplicate keys are not prohibited; parsers may keep first, last, or both. JavaScript's JSON.parse keeps the last. Python's json.loads keeps the last. Most validators flag this as a warning rather than an error.
  • Number precision: { "x": 0.1234567890123456789 }. JSON's number grammar accepts any decimal; double-precision float can only represent 15–17 significant digits. Python preserves precision; JavaScript rounds. Most tools display the original text and the parsed value side by side.
  • Unicode escapes: {"x": "\u00e9"} vs {"x": "é"}. Both should encode to the same bytes. Some validators normalize escape sequences on output; some preserve them. RFC compliance is "all forms are valid."

For adherence to RFC 8259, the strict JSON parsers (Python's json, Rust's serde_json, Go's encoding/json) are the most reliable. mytoolslist's validator uses a strict parser compatible with RFC 8259 and reports edge cases as warnings rather than errors.

Related Tools

Frequently Asked Questions

Is online JSON validation secure?

It depends on the tool's data handling. mytoolslist.com processes JSON entirely in-browser — your file is never uploaded to a server. This is the most secure model for sensitive configuration files. Other services vary: some store uploads temporarily with promises to delete within an hour; others retain indefinitely. For highly sensitive production config, use a tool that processes in-browser or runs locally via command line.

Why does my JSON show as "invalid" even though it looks right?

The most common causes are: invisible Unicode characters (non-breaking space \u00A0 instead of regular space — common when copying from Word documents), smart quotes (" instead of "), trailing commas, missing closing brackets, single quotes instead of double quotes. Open the document in a hex editor or od -c file.json to see invisible characters.

What is the maximum JSON file size the browser can parse?

Mainstream browsers (Chrome, Firefox, Safari, Edge) handle JSON.parse() up to about 250–500 MB before halting or crashing, depending on system memory. Practical limits: mytoolslist's /tools/json-validator accepts up to 50 MB reliably. Beyond that, switch to a streaming parser on a server or command-line tool.

Can I validate JSON with comments?

Standard JSON syntax does NOT allow comments. RFC 8259 is explicit on this point. To validate JSON-with-comments, use a JSON5 parser (VS Code's json5 plugin, Node.js's JSON5.parse(), or the jsonc parser). The mytoolslist JSON validator distinguishes: if comments are present, it suggests the JSON5 variant for parsing.

What is JSON Schema and when do I need it?

JSON Schema is a separate specification (Draft 2020-12 from json-schema.org) defining what valid JSON should look like for a specific use case. Use JSON Schema when: an API returns JSON for which you have a documented contract (OpenAPI), a config file has documented expected shape (VS Code's settings.json has a JSON Schema), or you want to validate user input on a form (validate form submit data against a schema before storing). Syntax validation answers "is this JSON?"; schema validation answers "is this the JSON I expected?"

Can I validate multiple JSON files at once?

Yes — concatenate them with newlines between (NDJSON format) and validate line by line. For independent full-JSON documents, batch through a server-side script (jq, Python with json, Node.js with stream-json) or a bulk-validator tool (ajv-cli, jsonschema CLI). mytoolslist's validator focuses on single-document UX.

What's the difference between "valid JSON" and "valid JavaScript object"?

JavaScript's object literal syntax is more permissive than JSON: it allows unquoted keys, single quotes, trailing commas, comments, methods (functions as values), undefined, NaN, Infinity, BigInt. JSON is a strict subset of JavaScript syntax but is not JavaScript. A { a: 1, b: undefined, c: function() {} } literal is valid JavaScript but invalid JSON. Converting: JSON.stringify(jsObject) produces valid JSON output by quoting keys, removing undefined, and skipping function values.