JSON Formatter, Validator & Type Generator
Format, minify, and generate types from JSON payloads up to 100MB+, no freeze.
Pasting a large JSON payload into most formatters either freezes the tab or hands back a wall of text you can't navigate. This one parses off the main thread, keeps the parsed value resident in that worker rather than copying it back, and lets you browse a huge document as a lazily-loaded tree or graph instead of one long scroll. Pretty-printing, minifying, and generating a matching type definition all read from that same parsed value.
How to format and validate JSON
- Paste your JSON into the Input box. To format a .json file, open it in any text editor, select everything, and paste it here, since the page has no file picker.
- Click Pretty print for two-space indentation, or Minify to strip every space and line break outside strings.
- If a red Parse error strip appears, the JSON is invalid: fix the spot the message describes and click the button again.
- Switch to Tree view or Graph view to expand big objects and arrays one level at a time, loading a hundred children per step.
- Use Copy or Download .json to take the complete formatted result with you.
Common JSON syntax errors and how to fix them
- Trailing comma, as in {"a": 1,} or [1, 2,]: delete the comma before the closing brace or bracket.
- Single quotes, as in {'name': 'Ada'}: JSON only accepts double quotes around keys and string values.
- Unquoted keys, as in {name: "Ada"}: that is a JavaScript object literal, so wrap each key in double quotes.
- Comments (// or /* */): plain JSON has no comment syntax, so strip them out or keep that file in a JSONC or JSON5 tool.
- NaN, Infinity or undefined as a value: none of them exists in JSON, so replace it with null, a number, or a quoted string.
- A raw tab or line break inside a string: escape it as \t or \n, because unescaped control characters are rejected.
- The error text itself comes from your browser's built-in JSON.parse, so its wording differs between Chrome, Firefox and Safari; most versions name a character position or a line and column to look at.
Why pasting a 100MB file doesn't lock the tab
Parsing happens in a Web Worker, and the worker keeps the parsed value in its own memory rather than sending the whole thing back to the page. That second part matters more than it sounds: structured-cloning a large object across the worker boundary is itself a slow, blocking copy, so avoiding it is what actually keeps the interface responsive on genuinely large input.
The tree and graph views ask the worker for one small page of children at a time, addressed by a path like users then 42 then tags, so opening a node in a million-entry array costs the same regardless of how big the rest of the document is. Every message that crosses back to the page stays small on purpose.
Pretty, minify, and the text view's display cap
Pretty-printing and minifying are worker operations too, run against the resident parsed value rather than the raw pasted text, so a document with inconsistent or missing whitespace still comes out normalized. The Text view that shows the result caps what it renders into the page at two million characters, because pushing a multi-hundred-megabyte string into a single textarea DOM node is its own separate performance problem, independent of parsing.
That cap is display-only. Copy and Download both act on the complete, untruncated string held in the worker, so a payload larger than the display cap still copies and downloads whole even though the on-screen preview stops partway through.
Generating a type from the shape it actually found
- TypeScript interfaces, matching arrays and optional fields to what the data contains
- Zod schemas, for runtime validation in a TypeScript project
- Python dataclasses via Pydantic models
- Rust structs annotated for Serde (de)serialization
- Go structs with generated field names and JSON tags
How the shape gets inferred
The generator walks the actual parsed value rather than working from a hand-written sample, builds a schema tree from what it sees, and merges repeated object shapes so an array of a thousand near-identical records produces one named type, not a thousand duplicate ones. Object shapes that differ get folded into a union instead of silently picking one and discarding the other fields.
This means the output is only as good as the sample you pasted. A field that is always a string in your document but sometimes holds a number in production will be typed as a string here, because the tool has no way to see records it wasn't given. Treat the generated type as a starting draft to review, not a schema contract to check in unread.
History, printing, and what leaves the browser
Recent pastes are indexed locally in the browser's own IndexedDB storage so you can pull a previous session back up, but this is a convenience index rather than a guaranteed archive: a payload past 500,000 characters is recorded with a preview and a timestamp only, not the full content, so it does not silently balloon local storage. Print / Save as PDF hands the formatted view to the browser's own print dialog, which is how you get a PDF: there is no PDF-generation library bundled into the page.
Nothing you paste is uploaded anywhere. The worker only ever receives text posted to it from this same tab, and the entire flow — parse, format, generate a type, browse the tree — runs without a single network request once the page has loaded.
JSON syntax rules at a glance
- Every key and every string value sits inside double quotes; single quotes are never valid.
- The literals true, false and null are lowercase only, so True, FALSE or NULL fail to parse.
- Numbers are plain decimals: no leading zeros like 007, no leading plus sign, no hex, and a digit on both sides of any decimal point.
- Items are separated by commas with none after the last one, and there is no comment syntax at all.
- The top level may be any single value, so a bare array, string or number is valid JSON too, not only an object.
- Files conventionally end in .json, and servers send them with the application/json media type.
Questions people ask about JSON Formatter & Type Generator
- Why does my huge JSON file look cut off in the text view?
- The text view stops rendering at two million characters purely to keep the browser tab from choking on a giant DOM node. It's a display limit only — the Copy button and the Download button both work against the complete parsed document, so what you save or copy is not cut off even when the preview is.
- Can I generate a database schema instead of a TypeScript type?
- Not directly. The five generator targets are TypeScript, Zod, Python via Pydantic, Rust via Serde, and Go structs — all in-memory data-shape languages, not SQL DDL. If you need a table schema, use the generated Pydantic or TypeScript type as a reference while writing the DDL by hand.
- Will the generated type always match my backend's real schema?
- Only as well as your pasted sample represents every case your backend can actually produce. The inference walks the one document you gave it; a field that's sometimes null or sometimes a different type in other records won't show up unless that variation was present in what you pasted. Review the output before relying on it.
- Does anything I paste get sent to a server?
- No. Parsing, formatting, and type generation all happen in a Web Worker inside your own browser tab, and that worker never makes a network call. You can confirm this yourself by opening your browser's network panel while pasting a document — nothing appears.
- How do I format a JSON file?
- Open the .json file in any text editor, copy its full contents, paste them into the Input box and click Pretty print. Download .json then saves the indented result as formatted.json, which you can rename or copy over the original.
- How do I fix 'Unexpected token' or other invalid JSON errors?
- That message is your browser's JSON parser stopping at the first character it could not accept. Look near the position it reports for a trailing comma, a single-quoted string, an unquoted key, a comment, or a value such as NaN or undefined, correct it, and run Pretty print again to surface the next problem, if any.
- Do I need an account to format or save JSON?
- No, there is no sign-in and no usage limit. Your 20 most recent pastes are kept as Recent snippets in this browser's IndexedDB, with anything over 500,000 characters stored as a short preview only; they never sync to other devices and disappear if you clear site data.
Related tools on BrakeTools
- Mock Data & Fake Database Generator — Generate up to 250,000 rows of realistic test data locally, export as SQL, JSON, CSV, or Excel.
- JWT Decoder — Decode and optionally verify a JWT's header, payload, and signature — never transmitted.
- API Request Builder & Tester — Build HTTP requests, inspect timing, headers, and responses, and copy cURL without sending request data through BrakeTools.
Content reviewed 2026-09-27.