Skip to main content
Tools Star Hub

Developer Tools

What Is JSON?

By Tools Star Hub Editorial Team · Published · Updated

JSON is a text format for objects and arrays. A value can be an object, an array, a string, a number, true, false, or null. Keys and strings use double quotes. {"name":"Ada","id":1} is valid JSON. The JSON Formatter pretty-prints it with two-space indents. A trailing comma, a comment, or a single-quoted key is not valid JSON, and the page reports the error instead of guessing.

APIs, config files, and browser tools pass data as JSON because the shape is strict and easy to parse. When a paste fails, the failure is usually a comma, a quote, or a comment left over from another language. Formatting the text makes the structure visible. It does not change the values.

What does valid JSON look like?

An object is a set of keys and values inside braces. An array is an ordered list inside brackets. Strings use double quotes. Numbers are plain digits, with an optional minus and fraction. true, false, and null are lowercase. There is no trailing comma after the last item.

Pretty-printing {"name":"Ada","id":1} inserts a line break after the opening brace, indents name and id by two spaces, and keeps the same two fields. Minifying removes that extra space. Both forms parse as the same JSON.

What Is JSON? — Tools Star Hub

Why does a familiar-looking paste fail?

{"a":1,} fails. The formatter reports invalid JSON at position 7 and says it expected a double-quoted property name. The comma after 1 leaves the parser looking for another key. Delete that comma.

{name: "Ada"} also fails, at position 1, because the key is not in double quotes. Comments with slashes, and strings in single quotes, fail for the same reason. They are allowed in some JavaScript files. They are not JSON. The page does not strip them for you.

What can you do with JSON after it parses?

Validate only checks the text. A successful check says This JSON is valid. Format and minify rewrite the spacing. Neither step sends the text to a server. The box accepts up to 750,000 characters.

An array of objects can become CSV. A single object cannot, until you wrap it in an array. JSON is also a common way to store settings. It is not a programming language, and it does not run code when you format it.

Numbers are not quoted. "1" is a string and 1 is a number, and they stay different after formatting. true, false, and null must be lowercase. True and FALSE are not JSON literals. If a field looks right in a spreadsheet and fails here, check the quotes and the case before you look for a deeper problem.

How to read and check JSON

  1. Paste the text. Include the outer braces or brackets. A fragment such as "name": "Ada" is not a complete JSON value.
  2. Validate or format. Validate reports success or the first problem. Format rewrites valid JSON with two-space indents. Minify puts it back on a tight line.
  3. Read the position when it fails. The message names a character position. Count from the start of the text, or look at the column it mentions, and check the comma or quote there.
  4. Copy the result you meant. Formatting does not rename keys or drop fields. If a field disappeared, it was not in the text you pasted.

Example

A small object

{"name":"Ada","id":1} formats as a brace, then "name": "Ada", then "id": 1, then a closing brace. Validation of that text says This JSON is valid.

A trailing comma

{"a":1,} is rejected at position 7. The parser expected another double-quoted property name after the comma. Removing the comma makes {"a":1}, which is valid.

Common mistakes

JavaScript object notation is looser

A trailing comma, a comment, or an unquoted key can be legal in a JavaScript file and still be illegal JSON. This page follows JSON.

One object is not a table

The CSV converter on this site wants an array of objects. A valid object still needs brackets around it before that conversion.

FAQ

Is {"name":"Ada","id":1} valid JSON?
Yes. The formatter pretty-prints it with two-space indents, and validation says This JSON is valid.
Why does {"a":1,} fail?
The trailing comma is not allowed. The page reports invalid JSON at position 7 and expected a double-quoted property name.
Can I use single quotes?
No. JSON strings and keys use double quotes. {name: "Ada"} fails at position 1.
Does formatting change the data?
It changes spacing only. Keys, numbers, and strings stay the same. Minify removes the spacing again.
Is the JSON uploaded?
No. Format, minify, and validate run in the browser. The box limit is 750,000 characters.

To pretty-print, minify, or validate a snippet, use the JSON Formatter. It runs in the browser.

To turn an array of objects into rows, read How to turn a JSON array into CSV.

JSON is not an encoding like Base64. Base64 wraps bytes. JSON describes values.