Text Tools
JSON Formatter & Validator
Format, validate and minify JSON, spot syntax errors and turn messy JSON into readable, indented text or a compact single line.
About the JSON Formatter & Validator
The JSON Formatter & Validator checks whether your JSON is valid as you type. If there's a mistake it shows the line, the column and a plain-English reason; if it's valid it formats it with 2 spaces, 4 spaces or tabs, or minifies it to one line. It can also sort keys, count keys, objects and arrays, and show the data as a collapsible tree.
What you can do with the JSON Formatter & Validator
- Live validation: Errors show the line, column and a plain-English reason.
- Format or minify: 2 spaces, 4 spaces, tabs, or one compact line.
- Tree view: Explore the data in a collapsible tree.
- Extras: Sort keys and count keys, objects and arrays.
The rules JSON is strict about
Keys and strings must use double quotes, not single quotes. No trailing comma is allowed after the last item in an object or array. Comments aren't allowed. The values true, false and null must be lowercase. Breaking any of these makes the whole document invalid, and the error box tells you which rule was broken and where.
Format, minify or explore
Formatting adds line breaks and indentation, so nested data is easy to read and debug. Minifying strips unnecessary spaces to make the data as small as possible. The tree view lets you open and close nested objects, with strings, numbers, booleans and null shown in different colours.
Safe for private data
JSON often contains API keys, tokens or personal data. This tool runs entirely in your browser, so nothing you paste is sent to a server.
Related tools
Frequently Asked Questions
Why is my JSON invalid?
The most common causes are single quotes, a trailing comma, missing quotes around a key, or a comment. The error box shows the line and column and what went wrong.
Can I sort the keys?
Yes. Switch on "Sort keys A → Z" to sort every object's keys alphabetically, at every level.
Does formatting change my data?
No. Only whitespace changes; keys, values and order stay the same unless you choose to sort keys.
How do I format or beautify JSON?
Paste your JSON into the box. If it is valid, the Formatted JSON box shows it indented with 2 spaces by default. Pick 4 spaces or Tabs under Output style if you prefer, then use the Copy or Download button above the result.
How do I minify JSON to one line?
Choose Minify under Output style. The tool removes all line breaks and extra spaces, and the size stats show the input and output sizes so you can see how many bytes you saved. Minifying does not change any keys or values.
Why does single-quoted JSON fail?
The JSON standard only allows double quotes around keys and text values. Something like {'name': 'Ravi'} is valid in JavaScript or Python but not in JSON, and the tool will report "Keys need double quotes, not single quotes" with the line and column.
Are comments allowed in JSON?
No. Standard JSON has no comments, so a line starting with // or a slash-star block comment makes it invalid. Remove the comments before validating. Some config files use JSONC or JSON5, which allow comments, but those are separate formats.
What do the Keys, Objects, Arrays and Max depth numbers mean?
Keys is the total number of keys across every object, Objects and Arrays count each { } and [ ] block, and Max depth is how many levels deep the nesting goes. They help you check the size and shape of an API response at a glance.
How do I explore a large JSON response?
Open the Tree view below the result. Objects show how many keys they have and arrays how many items, and you can expand or collapse each level. Very large data is trimmed to the first 600 items in the tree, but the formatted text is complete.
What does "Extra text after the end of the JSON" mean?
A JSON document must be one value, such as a single object or array. This error usually appears when two objects are pasted one after another or there is a stray bracket at the end. Wrap multiple objects in [ ] with commas between them.
Is it safe to paste API keys or customer data here?
The JSON is checked and formatted by JavaScript in your browser, so it is not sent to a server by this tool. Even so, it is good practice to remove passwords, tokens and personal data before pasting into any online tool.
Read the guide
Related tools
- HTML Entity Encoder & Decoder, Escape < > & and quotes into HTML entities so they display as text, or unescape entities back to characters.
- Roman Numeral Converter, Convert numbers 1–3999 into Roman numerals and Roman numerals back into numbers.
- Word & Character Counter, Count words, characters (with and without spaces), sentences and paragraphs, plus reading and speaking time, live as you type.
- Palindrome Checker, Check whether a word, phrase or number reads the same forwards and backwards, ignoring spaces, punctuation and capitals.
- Find & Replace, Find every occurrence of a word or phrase and replace it, with match-case and whole-word options and a count of replacements.
- Lorem Ipsum Generator, Generate Lorem Ipsum as paragraphs, sentences, words or list items, in short, medium or long lengths, as plain text or HTML.