JSON Formatter
Beautify, validate and minify JSON.
Input
Valid JSONLn 1, Col 145 lines, 780 B
45 lines, 780 B
A JSON formatter, validator and fixer in one page
Paste your JSON and it is checked as you type. If it is valid, you can format it, minify it, search it, convert it or compare it with another file. If it is broken, the tool shows exactly where the problem is and, most of the time, gives you a fix you can apply with one click.
- Format and minify. Make messy JSON easy to read with 2, 3, 4 or 8 spaces, or tabs. Or squeeze it onto one line with Minify. You can also sort keys A to Z or Z to A, and escape or unescape JSON to use it inside a string.
- Clear error messages. When your JSON is invalid, you see the line and column, the code around it, and a plain explanation. Press Apply fix for the most likely repair, or Fix all if there are several problems.
- Fixes broken JSON. Single quotes, unquoted keys, comments, trailing commas, Python
True/False/None,NaN, missing commas, wrong brackets and cut-off endings can all be repaired. Every repair is listed, so nothing changes behind your back. - Tree view with search. Open and close any branch of a big document, and search keys and values to jump straight to what you need.
- Convert to other formats. Turn JSON into YAML, XML, CSV or TypeScript. CSV can use a comma, semicolon, tab or pipe. TypeScript can be
interfaceortype, with or withoutexport. - JSONPath queries. Pull values out of a large response with paths like
$.users[*].name. Slices like[0:2], searching every level with.., and filters like[?(@.age > 30)]all work. - Compare two documents. Paste a second JSON and see every value that was added, removed or changed, each with its full path. Comparing two API responses takes seconds.
- Size and structure stats. See the input, formatted, minified and gzipped size, plus depth, key count, and how many strings, numbers, booleans and nulls you have.
How this JSON formatter compares with other online tools
Most online formatters stop at pretty-printing. The comparison below describes what you usually get from a basic formatter and what this one adds.
| Feature | Typical online formatter | This tool |
|---|---|---|
| Your data | Some tools send the text to a server to process it. | Everything runs in your browser. Nothing you paste or open is uploaded. |
| Invalid JSON | A one-line message such as "Unexpected token". | Line, column, a code excerpt, an explanation, and an Apply fix or Fix all button. |
| Pasted from code or chat | Fails on const data = {...}; or on a markdown fence. | Offers a one-click fix that strips the wrapper or the fence, then formats what is inside. |
| Converting | A separate page per format. | YAML, XML, CSV and TypeScript in the same tool, from the same input. |
| Finding data | Scroll, or use the browser find box. | Searchable tree plus JSONPath with filters, slices and recursive search. |
| Comparing | A separate diff tool that compares raw text. | Compares values, so key order and whitespace do not show up as changes. |
| Output settings | Two or four spaces. | Indent of 2, 3, 4, 8 or tab, key sorting, inline short arrays, non-ASCII and slash escaping. |
| Large files | The page freezes or the paste box truncates. | Open files up to 25 MB, with undo and redo and a full screen editor. |
How to format and fix JSON
- Paste your JSON into the Input box, drop a .json file onto it, or press Open file. The status badge shows Valid JSON, Repaired or Invalid as you type.
- If the badge says Invalid, read the line and column in the error card and press Apply fix. When the card shows Fix all, one click applies the whole chain.
- Press Format (Ctrl or Cmd + Enter) for readable output or Minify (Ctrl or Cmd + Shift + Enter) for the smallest size.
- Open Settings to change indentation, sort keys, or escape non-ASCII characters and slashes.
- Copy the result or download it as a file. Use the Tree, Convert, Query, Compare and Stats tabs for anything beyond formatting.
Common JSON errors and what the fix does
| Problem | Example | Fix |
|---|---|---|
| Trailing comma | {"a": 1,} | The comma is removed. |
| Single quotes | {'a': 'b'} | Converted to double quotes. |
| Unquoted key | {a: 1} | The key is wrapped in quotes. |
| Comment | {"a": 1} // note | The comment is removed. |
| Missing comma | {"a": 1 "b": 2} | A comma is inserted between the two. |
| Wrong closing bracket | [1, 2, 3} | The } becomes ]. |
| Cut-off document | {"a": [1, 2 | The missing ] and } are added. |
| Python or JavaScript values | {"ok": True, "n": None} | Becomes true and null. |
JSON formatter FAQ
Is my JSON uploaded anywhere?
No. Parsing, formatting, repairs, conversion, queries and comparison all run in your browser, and the text is not sent to a server. That makes it safe to use with API responses, config files and other data you would not paste into a site that uploads it.
Why does my JSON say Invalid?
The most common causes are a trailing comma, single quotes instead of double quotes, an unquoted key, a missing comma between two items, or a bracket that never closes. The error card names the line and column and shows the code around it. JSON is stricter than JavaScript, so something that works as a JavaScript object can still be invalid JSON.
What does Repaired mean, and is it safe?
Repaired means the input was not strict JSON, but the tool could read it by fixing small, unambiguous problems such as comments, trailing commas or single quotes. Every change is listed so you can check it. Turn off Auto-repair in Settings if you want strict validation only. Two documents pasted back to back are never merged automatically, because guessing there could change your data.
What is the difference between formatting and minifying?
Formatting adds line breaks and indentation so a person can read the document. Minifying removes all optional whitespace to make it smaller for sending or storing. Both produce the same data. The Stats tab shows how many bytes each version takes, including the gzipped size.
How do I query a specific value out of a large JSON file?
Open the Query tab and enter a JSONPath expression. $.users[*].email returns every email, $..id finds every id at any depth, $.users[0:2] returns the first two users, and $.users[?(@.active == true)] keeps only the active ones. The matches are listed with their paths and can be copied as a JSON array.
Can it convert JSON to CSV, YAML, XML or TypeScript?
Yes, from the Convert tab. CSV works best with an array of objects and lets you pick the delimiter. TypeScript output generates interface or type declarations from the shape of your data, which is useful for typing an API response.
How big a file can I open?
Files up to 25 MB. Very large documents are slower to highlight in the editor, but formatting, the tree and queries still work. If the page feels slow, switch the editor to a compact height or use the Tree and Query tabs instead of scrolling the raw text.
Does the order of keys matter in JSON?
The JSON specification treats an object as an unordered set of keys, so most programs do not care about order. Sorting keys A to Z is still useful for readable diffs and for committing config files without noise. The Compare tab ignores key order, so reordered keys are not reported as changes.