JSON Formatter & Validator

JSON is the lingua franca of APIs, build configs, and feature flags, but one stray comma can stop a deploy. This formatter pretty-prints nested objects for reading, minifies payloads for compact transport, and validates structure so you see where a parser gave up. Paste a response body, a package manifest fragment, or a misbehaving webhook payload and repair the syntax before you chase application bugs. Strict JSON rejects comments and trailing commas even when JavaScript object literals allow them. Keeping validation local lets you tidy data without uploading customer payloads to an unknown server, while still teaching the same rules production parsers enforce.

Informational only; verify critical results independently.

How to use

  1. Paste JSON from an API client, log line, or configuration file into the editor area.
  2. Run Format to apply consistent indentation so nested objects and arrays are easy to scan.
  3. Run Minify when you need a single-line payload for an environment variable or compact HTTP body.
  4. Read validation messages carefully; line or position hints usually point to the first hard syntax error.
  5. Remove trailing commas after the last property or array element—JSON does not allow them.
  6. Replace single quotes with double quotes around keys and string values, which strict JSON requires.
  7. Strip // or /* */ comments, or move commentary out of the file, because standard JSON parsers reject comments.
  8. Redact live tokens and personal data before sharing screenshots; local processing still deserves good hygiene.
  9. After fixing, format again to confirm the document parses and the structure matches your mental model.
  10. Copy the cleaned JSON back into your editor, test suite fixture, or HTTP client for the next request.

Examples

  • Minified {"a":1,"b":[2,3]} → pretty-printed with indented keys on separate lines.
  • Invalid {"a":1,} → error on trailing comma; remove the comma after 1 then revalidate.
  • Almost-JSON {'ok': true} → replace single quotes and ensure true is unquoted boolean.
  • GeoJSON FeatureCollection paste → format to verify geometry arrays before committing.
  • package.json fragment with comment → strip the comment line so npm-compatible JSON remains.
  • Minify a multi-line config → one line suitable for an INLINE_JSON environment variable.
  • 400 Bad Request body with missing ] → formatter highlights where the array never closed.
  • Unicode string "café" and "✓" → remains valid; formatting preserves UTF-8 text in strings.
  • Duplicate visual keys after format → easier to spot accidental repeated property names in objects.
  • Tab-indented dump → reformat to two-space indentation to match a team style guide.

FAQ

Why doesn’t JSON allow comments?
The JSON specification keeps the format as a pure data interchange subset. Comments belong in surrounding documentation or in formats like JSONC/JSON5 when your toolchain explicitly supports them. For APIs and many package managers, delete comments before shipping.
What is the most common syntax failure?
Trailing commas, single-quoted strings, and unquoted keys top the list for people coming from JavaScript object literals. Fix those three before hunting exotic Unicode escapes. A validator that stops at the first error is doing its job.
When should I minify versus pretty-print?
Pretty-print for humans and code review. Minify for wire size, query string experiments, or config fields that expect one line. Minification does not change meaning if the document was already valid—it only removes insignificant whitespace.
Can this handle very large JSON files?
Browser memory and UI responsiveness set practical limits. Multi-megabyte documents may lag. For huge logs or database dumps, command-line tools such as jq stream more reliably than a web text box.
Why did key order change after formatting?
Some pipelines parse into maps that reorder keys; others preserve insertion order. JSON object semantics treat names as unordered even though many engines keep order for convenience. Do not rely on key order for application logic.
Are duplicate keys allowed?
The RFC discourages duplicate names; parsers pick a winner inconsistently. Formatting can make duplicates easier to see. Prefer unique keys and merge structures intentionally rather than depending on last-key-wins behavior.
How are numbers like 1e10 or leading zeros treated?
JSON allows exponential notation for numbers. Leading zeros on integers (such as 01) are invalid in strict JSON. Keep IDs that need leading zeros as strings, for example "001".
Can I paste JSON Lines (NDJSON)?
Newline-delimited JSON is a sequence of values, not one JSON document. Paste a single object or array here. For NDJSON, validate each line separately or use tools designed for stream formats.
Does formatting change floating-point values?
A parse-and-serialize cycle can normalize how numbers are printed. Usually values remain equal, but extremely precise decimals may appear in a different textual form. For bit-exact text preservation, avoid re-encoding and only fix syntax elsewhere.
What about Date objects or undefined from JavaScript?
JSON has no Date type or undefined. Dates travel as ISO strings; undefined properties are typically omitted. If your dump shows bare identifiers from console.log of JS objects, convert them to JSON-legal types before validating.
Is JSON the same as a JavaScript object literal?
Related but stricter. JSON requires double-quoted keys, disallows functions, and forbids trailing commas and comments. Treating them as identical causes avoidable parser failures when moving data between languages.
Is pasted JSON uploaded to Vastorae?
Parsing and formatting run in your browser. That reduces exposure versus an online “upload my file” service, but you should still redact secrets before sharing screen contents or hanging around on untrusted machines.

Formula / Method

Validation parses the input with a strict JSON grammar: objects of string keys to values, arrays, strings, numbers, booleans, and null. Pretty-printing re-serializes the parsed structure with indentation. Minification re-serializes without insignificant whitespace. If parsing throws, the document is invalid and formatting cannot proceed until syntax is repaired. Semantic equality is structural; insignificant spacing does not change meaning.

Assumptions & Limitations

This tool validates and reformats JSON text; it does not enforce application schemas (JSON Schema), OpenAPI contracts, or business rules. Comments and JSON5 extensions are out of scope unless stripped first. Extremely large payloads may hit browser limits. Re-serialization may normalize number formatting. Local processing is not a substitute for secure handling of regulated data.

Related guides

Related tools

Last updated: 2026-07-13