JSON Formatter, Validator & Beautifier
Paste any JSON into the box above and this online JSON formatter will clean it up instantly. It adds proper indentation, checks for errors, and tells you exactly where something is wrong — with the line and column number. You can also sort keys, fix broken JSON in one click, compare two JSON files side by side, escape or unescape strings, minify JSON to one line, and export to CSV, YAML, or TypeScript. Everything runs in your browser — nothing is sent anywhere.
What Is JSON?
JSON stands for JavaScript Object Notation. It is a simple way to store and share data as text. Even though it has "JavaScript" in the name, you can use JSON with any programming language — Python, Java, Go, PHP, C#, and many more all support it.
JSON data is built from two things. The first is an object — a group of key and value pairs wrapped in curly braces {}. Think of it like a dictionary where each word has a meaning. The second is an array — an ordered list of items wrapped in square brackets []. Values inside JSON can be text (always in double quotes), numbers, true, false, null, or other objects and arrays.
JSON files end with the .json extension and are plain text, so you can open them in any text editor. They are used everywhere — APIs send data as JSON, apps store settings in JSON files like package.json, and databases like MongoDB store records in a JSON-like format. When a JSON file is very large or deeply nested, a JSON viewer makes it much easier to read by showing the structure as a clickable, collapsible tree.
How to Format and Validate JSON
Formatting JSON means adding spaces, line breaks, and indentation so it is easy for a person to read. This is also called pretty printing or beautifying. Validating JSON means checking that it follows the correct rules so that computers can read it without errors.
- 1Paste your JSON — copy your JSON from anywhere — an API, a log file, a config file — and paste it into the editor at the top of this page.
- 2Pick your indent style — choose 2 spaces (default), 4 spaces, or tabs. The tool applies the same spacing at every level of your data.
- 3Click Format — the JSON validator checks your data for errors. If it is valid, the output is pretty-printed and easy to read. If there is an error, you see the exact line number and position of the problem.
- 4Sort, minify, or convert — you can sort all keys from A to Z, minify the JSON down to one line, or switch to the Tree, Table, Diff, or Convert tabs to explore and export your data in different ways.
- 5Copy or download — click Copy to put the formatted JSON on your clipboard, or download it as a
.jsonfile.
Tool Features
This JSON formatter does more than just format. Here is what each feature does and when to use it.
1Auto-Repair & JSON Fixer
Sometimes JSON copied from Python code or logs is not quite right. It might have single quotes instead of double quotes, a comma after the last item, or keys without quotes around them. The JSON fixer finds these problems and corrects them in one click. It also converts Python values like True and None to the correct JSON versions.
2JSON Viewer & Collapsible Tree
The JSON viewer turns your data into a clickable tree. You can open and close any part of it to focus on what you need. Use the search box to find a key or value quickly. You can also copy the full path to any field — for example users[0].address.city — straight to your clipboard.
3JSON to Table View
If your JSON is a list of objects — like a list of users or orders — the table view turns it into rows and columns, just like a spreadsheet. You can sort by any column, filter rows by typing, and page through large lists. This is much easier than reading through raw JSON line by line.
4JSON Diff & Side-by-Side Compare
The JSON compare tool shows two JSON files next to each other and highlights everything that is different. New keys are shown in green, deleted keys in red, and changed values in amber. This is useful when you want to check what changed between two API responses or two versions of a settings file.
5JSON to TypeScript Types
Paste a JSON object and get TypeScript interfaces ready to use in your code. The tool figures out the type of each field automatically — string, number, boolean, null, nested object, or array. This saves time when you start working with a new API and need to set up types quickly.
6CSV & YAML Conversion
Need your data in a spreadsheet? Convert JSON arrays to CSV and open them in Excel or Google Sheets — each key becomes a column, each item becomes a row. You can also convert JSON to YAML, which is a popular format for writing config files in tools like Kubernetes and GitHub Actions. Both directions are supported.
Common JSON Syntax Errors and How to Fix Them
JSON is strict about its rules. One small mistake — a missing quote, an extra comma — and the whole thing breaks. The JSON linter tells you exactly where the error is, and the JSON repair tool can fix the most common mistakes for you automatically.
| Error | Cause | Auto-Repair |
|---|---|---|
Unexpected token ' | Single quotes used instead of double quotes for keys or string values | ✓ Fixed |
| Trailing comma | {"a":1,} — comma after the last item in an object or array | ✓ Fixed |
| Unquoted key | {name: "John"} — key is not wrapped in double quotes | ✓ Fixed |
| // or /* */ comment | JavaScript-style comments embedded in JSON — invalid per RFC 8259 | ✓ Stripped |
| Python literals | True, False, None — must be true, false, null | ✓ Fixed |
| Unterminated string | A string value is missing its closing double quote | Manual fix needed |
When the auto-repair cannot fix a problem on its own, the JSON validator tells you exactly where the issue is — for example, Line 14, Column 23: Unexpected token. You can then go to that spot and fix it yourself.
Escaping and Unescaping JSON Strings
Sometimes a JSON object gets stored as text inside another JSON field — for example in a log file or a database record. When that happens, certain characters inside the text need to be escaped, meaning a backslash (\) is added in front of them so the parser does not get confused.
| Character | Escaped Sequence | Description |
|---|---|---|
| " | \" | Double quote |
| \ | \\ | Backslash |
| (newline) | \n | Line feed |
| (tab) | \t | Horizontal tab |
| (carriage return) | \r | Carriage return |
| (unicode) | \uXXXX | Unicode code point (4 hex digits) |
The Escape tool takes your JSON and adds backslashes wherever they are needed, so it is safe to store as a string. The Unescape JSON tool does the opposite — it takes escaped text and turns it back into normal, readable JSON. For example, "{"id":1,"name":"Alice"}" unescapes into {"id":1,"name":"Alice"}.
JSON Minification and Compression
JSON minification removes all spaces, line breaks, and indentation and squashes everything onto one line. The data and structure stay exactly the same — only the whitespace is removed. A formatted JSON file with 4-space indentation can be two to four times bigger than the minified version.
Why minify? When you send JSON over the internet — in an API request or HTTP response — a smaller file means faster transfer and lower bandwidth usage. The JSON minifier on this page gives you the smallest possible version of your data with nothing missing.
Private Browser Processing
Everything on this page — formatting, validating, sorting, minifying, escaping, comparing, and converting — runs inside your browser. Your JSON data, API keys, passwords, and any sensitive information never leave your device and are never sent to any server.
Frequently Asked Questions
What is a JSON file and what is it used for?▾
{}) and arrays (lists inside square brackets []). JSON files end in .json and are used everywhere — APIs send responses as JSON, apps store settings in JSON files, and databases like MongoDB use a JSON-like format. You can open any JSON file in a simple text editor, but a JSON viewer makes it much easier to navigate.Can I add comments to a JSON file?▾
// or /* */ comment to a JSON file, any parser will throw an error when it tries to read the file. If you have comments in your data — for example copied from a tsconfig.json file which uses a format called JSONC — use the Auto-Repair tool to remove them and get back valid JSON.How do I open and read a JSON file?▾
What is the difference between JSON formatting and JSON minification?▾
How do I compare two JSON payloads to find differences?▾
How do I escape or unescape a JSON string?▾
\" for double quotes and \\ for literal backslashes, with \n and \t for newlines and tabs. The Escape tool adds these backslashes automatically. The Unescape JSON tool reverses the process, converting a serialized string such as "{"id":1}" back into a readable JSON object for formatting and inspection.