Menu

JSON Formatter

Format, validate, and explore JSON with a live tree view.

Last updated

Indent
InputPaste JSON to begin
Output
Formatted JSON appears here — reindent, validate, and copy in one click.

What is a JSON formatter?

A JSON formatter (also called a JSON beautifier or pretty-printer) takes compact or messy JSON and turns it into readable, indented data. It is one of the most reached-for developer tools — used while inspecting API responses, reading config files, debugging logs, comparing test fixtures, and moving data between frontend and backend code.

JSON is a strict format: keys must be in double quotes, strings must be in double quotes, commas must be in the right place, and every opening { or [ must be closed. A formatter makes that structure visible, and a built-in validator tells you exactly where the syntax breaks if it does.

JSON stands for JavaScript Object Notation. Although it grew out of JavaScript, almost every programming language has built-in support for reading and writing JSON, which is why it has become the default way to exchange structured data on the web.

What you'll learn while using it

  • Objects use {} for named fields, arrays use [] for ordered lists, and both can be nested inside each other to any depth.
  • Pretty JSON and minified JSON are the *same data* — whitespace changes readability, not meaning. Servers usually return minified JSON to save bytes.
  • JSON values are limited to six types: string, number, boolean, null, object, and array. There is no undefined, no functions, and no comments.

How to format JSON step by step

  1. Paste your JSON into the input box

    Copy the JSON from your API response, log file, or config and paste it on the left. The formatter accepts both minified and partially formatted input.

  2. Choose your indent width

    Two spaces is the most common style; four spaces is also widely used. Pick whichever matches your project's existing style.

  3. Read the validation result

    If the JSON is valid, the formatted output appears on the right. If it isn't, the error message tells you the line and character where parsing failed.

  4. Explore the tree view

    Use the collapsible tree to fold deeply nested objects and arrays. This is the fastest way to understand the shape of an unfamiliar API response.

  5. Copy or minify the result

    Copy the pretty-printed version into your code or docs, or minify it back to a single line for storage and network transport.

JSON syntax quick reference

The complete set of JSON building blocks. Anything outside this list is not valid JSON. Specification: RFC 8259 and ECMA-404.

TokenMeaningExample
{ }Object — collection of key/value pairs{"name": "Maya"}
[ ]Array — ordered list of values[1, 2, 3]
"..."String — always wrapped in double quotes"hello"
NumberInteger or float, no quotes, no leading +42, -3.14
true / falseBoolean values, lowercasetrue
nullEmpty / missing valuenull
:Separator between a key and its value"id": 7
,Separator between items — never trailing[1, 2, 3]

JSON examples to try

Pretty-print a typical API response

Input
{"user":{"id":7,"name":"Maya"},"skills":["HTML","JavaScript"]}
Formatted
{  "user": {    "id": 7,    "name": "Maya"  },  "skills": ["HTML", "JavaScript"]}

After formatting, the nested user object and the skills array become much easier to scan. The data is identical — only the whitespace changes.

Catch a trailing comma

Invalid
{  "name": "Coddy",  "active": true,}

JSON does not allow a trailing comma after the last property. The validator will flag the closing }. This is one of the most common mistakes when copying JavaScript object syntax into JSON.

Compare value types

Input
{  "count": 3,  "countText": "3",  "enabled": true}

3 is a number, "3" is a string, and true is a boolean — three different JSON types. APIs often fail when the shape is right but a value type is wrong.

Read a deeply nested response

Input
{  "data": {    "orders": [      { "id": 101, "items": [{ "sku": "A", "qty": 2 }] },      { "id": 102, "items": [] }    ]  }}

Use the tree view to collapse data.orders and reveal the shape one level at a time. Nested arrays of objects are the most common pattern in REST responses.

Common JSON mistakes

  • Using single quotes instead of double quotes around keys or strings — JSON only allows double quotes.
  • Treating JSON like a JavaScript object: comments, functions, and undefined are not valid in JSON, and trailing commas will fail to parse.
  • Forgetting that numbers in JSON cannot have a leading +, leading zeros (except 0 itself), or be wrapped in quotes if you actually want a number type.

JSON Formatter FAQ

What is JSON?
JSON (JavaScript Object Notation) is a lightweight text format for structured data. It uses key-value pairs and arrays and is supported by virtually every programming language, which makes it the default for web APIs, config files, and message payloads.
How do you format JSON?
Paste the JSON into a JSON formatter, choose an indent width (usually 2 spaces), and the tool re-emits the same data with line breaks and indentation. Most formatters also validate the syntax in the same step.
What is the difference between a JSON formatter and a JSON validator?
A formatter changes valid JSON into a more readable layout. A validator checks whether the JSON syntax is valid in the first place. A good JSON tool does both.
Does pretty-printing JSON change the data?
No. Pretty-printing adds indentation and line breaks, but the keys, arrays, strings, numbers, booleans, and null values stay exactly the same. Minifying it back will reproduce the original network-friendly form.
Why does my JSON fail if it looks like a JavaScript object?
JSON is stricter than JavaScript object syntax. Keys and strings must use double quotes, JSON cannot contain comments, and trailing commas, single quotes, and undefined are not allowed.
Where do developers use JSON every day?
JSON is everywhere: REST and GraphQL responses, request bodies, configuration files (package.json, tsconfig.json), package metadata, log lines, browser local storage, and test fixtures.

Learn more

Other developer tools

Learn to code with Coddy

GET STARTED