Just Formatter

JSON Formatter

Indent:
1
Tree

Online JSON Formatter, Validator & Beautifier

Paste raw, minified, or broken JSON and get clean, indented output with a single click. When the syntax is invalid, the error message includes the exact line number and character position — not just "unexpected token". Everything runs in your browser using JavaScript.

There is no upload limit, no account, and no data sent to any server. Paste your JSON and the formatter handles indentation, minification, and copy-to-clipboard output — all client-side.

What this tool does

  • Format minified JSON into readable output
  • Validate JSON and show exact error line numbers
  • Minify JSON for API payloads
  • Copy formatted output to clipboard
  • All processing stays in your browser

JSON Data Types Reference

JSON supports exactly six value types. Every valid JSON document is built exclusively from these primitives:

string
"Hello, world!"
Text enclosed in double quotes. Single quotes are not valid JSON. Backslash is the escape character: \n (newline), \t (tab), \" (quote), \\ (backslash).
number
42 3.14 -7 1.5e10
Integer or floating-point. No NaN, Infinity, or hexadecimal literals — those cause parse errors. Very large integers lose precision in languages that use IEEE 754 doubles (JavaScript included).
boolean
true false
Lowercase only. True or False (capitalized) are syntax errors. Often confused with the strings "true" and "false", which are different — a string requires quotes.
null
null
Represents an absent or empty value. Lowercase only. Used to indicate a field exists but has no value, distinct from a missing key.
array
["a", 1, true, null]
Ordered list of any value types. Elements are comma-separated inside square brackets. Arrays can be nested and can contain mixed types. A trailing comma after the last element is a syntax error.
object
{"key": "value", "count": 3}
Unordered collection of key-value pairs. Keys must be strings in double quotes. Values can be any JSON type. Duplicate keys are technically allowed by the spec but behavior is undefined — most parsers keep the last value.

Common JSON Errors and How to Fix Them

These are the most frequent JSON syntax errors developers encounter. Paste your broken JSON into the formatter above to find the exact line of the error.

Trailing comma

A comma after the last property of an object or the last element of an array is invalid JSON. JavaScript allows trailing commas in code, which trips up developers who hand-write JSON config files.

Invalid

{"name": "Alice", "age": 30,}

Fix

{"name": "Alice", "age": 30}

Single-quoted strings

JSON requires double quotes for both keys and string values. Single quotes and unquoted keys are valid JavaScript object syntax but not valid JSON.

Invalid

{name: 'Alice'}

Fix

{"name": "Alice"}

Unexpected token < at position 0

Your API call received an HTML error page instead of JSON. This usually means a 404 or 500 error. Check the HTTP response status code and the endpoint URL.

Invalid

<!DOCTYPE html>...

Fix

Check the request — the server returned HTML, not JSON.

Comments in JSON

Standard JSON does not support comments. Config files like tsconfig.json use JSONC (JSON with Comments). If you need comments, use a JSONC-aware parser or move comments out-of-band.

Invalid

{"host": "localhost" // dev only}

Fix

Remove the comment. Use JSONC format for comment support.

Missing comma between properties

Each key-value pair in an object must be separated by a comma. Missing commas are easy to introduce when adding new fields to existing JSON.

Invalid

{"a": 1 "b": 2}

Fix

{"a": 1, "b": 2}

Unescaped special characters in strings

Backslashes in string values must be escaped as \\. Newlines must be \n, not an actual line break inside a string value.

Invalid

{"path": "C:\Users\Alice"}

Fix

{"path": "C:\\Users\\Alice"}

JSON Formatting in Practice: APIs, Config Files, and Debugging

JSON is the de facto data interchange format for REST APIs. When you call an API endpoint and the response is a wall of minified text, pasting it into a formatter immediately reveals the structure — the nested objects, the array lengths, the exact field names. This is the most common use case for a JSON formatter in day-to-day development.

API debugging pattern: Copy the raw response from your browser's DevTools Network tab (right-click → Copy → Copy Response), paste it into Just Formatter, and use the prettified output to understand what the API is actually returning. If the formatter throws an error, the response is not valid JSON — check the Content-Type header and HTTP status code.

Configuration files like package.json, tsconfig.json, and appsettings.json must be valid JSON (or JSONC). A misplaced comma or missing brace will break your build or runtime. Use the validator before committing config changes.

Minification is the reverse — taking readable JSON and removing all whitespace to produce the smallest possible representation. Useful for reducing API payload size or embedding JSON literals in code. The minify button produces compact output you can paste directly into a request body or a string constant.

JSON Schema Validation vs. Syntax Validation

There are two different types of JSON validation that developers often confuse:

Syntax Validation

Checks whether the document is valid JSON — correctly quoted strings, balanced brackets, no trailing commas. This is what Just Formatter does. A syntax-valid document can be parsed by any JSON parser.

Schema Validation

Checks whether the document conforms to a specific structure — required fields, value types, format constraints (like "email" or "date-time"). Requires a JSON Schema definition and a schema validator library.

If your JSON is syntactically valid but your API is still rejecting it, the issue is probably schema validation — a required field is missing, a string is in the wrong format, or a number is out of the allowed range. Read the API error response carefully; schema validators typically return specific field-level error messages.

For a deeper look at the difference, see the blog post on JSON Schema validation vs. JSON Lint.

Frequently Asked Questions

Why does my JSON fail to parse even though it looks correct?

The most common culprits are a trailing comma after the last element, single-quoted strings instead of double-quoted, or an actual HTML error response being mistaken for JSON. Paste it into the formatter above — the error message includes the exact line and character position.

What is the difference between JSON.parse() and JSON.stringify()?

JSON.parse() converts a JSON string into a JavaScript object. JSON.stringify() converts a JavaScript object back into a JSON string. The formatter above uses JSON.parse() for validation and JSON.stringify(result, null, 2) for prettifying with 2-space indentation.

Can I format very large JSON files?

Yes. The formatter runs entirely in your browser with no file size limit imposed by the tool. Files over 10 MB may slow down the browser tab during parsing. For very large datasets, consider using a CLI tool like jq or Python's json.tool module instead.

Why can't JSON have comments?

Douglas Crockford, who standardized JSON, deliberately excluded comments to prevent developers from using JSON files as configuration with embedded directives. If you need comments in config files, use JSONC (supported by TypeScript and VS Code) or YAML instead.

Is my JSON data secure when I paste it here?

All processing runs in your browser using JavaScript. Nothing is sent to a server. You can verify this by watching the Network tab in your browser's DevTools while using the formatter — no outbound requests are made.

From the Blog

Related Tools