JSON Beautifier
Getting started3 min read

How to Create a JSON File: Syntax, Examples, and Validation

Create a small JSON document, check its syntax, and save it as a .json file. Learn how to choose types, represent multiple records, and avoid the mistakes that cause parser errors.

Create and download formatted JSON

Write one complete JSON value

A JSON file contains one complete value. Objects are a natural fit for settings or a single record; arrays are useful for a list of records. Choose the structure that matches the program that will read it rather than assuming every file must start with an object.

This example describes one user. The field names and text values use double quotes. The age is a number, active is a boolean, and manager is explicitly empty.

A complete JSON document
{
  "name": "Alice",
  "age": 30,
  "active": true,
  "manager": null,
  "roles": ["editor", "admin"]
}

Choose the right types

Keep text identifiers as strings, even when they contain only digits. A postcode such as "00123" is a label, not a number to calculate with. Represent a yes/no value with true or false when the application expects a boolean.

Dates have no special JSON type. Use a documented string format agreed with the reader, and use schema validation when you need a date format check. A string field with the text "null" is different from the JSON value null.

Add multiple records as an array

To store several users, wrap the individual objects in square brackets and separate them with commas. Do not concatenate two object documents into the same file. A strict parser expects a single complete value.

Consistent record fields help when exporting to a table, but JSON itself does not require every object to contain the same keys. Missing fields and null values are different; decide which convention your application uses.

An array of records
[
  {"id":"00123","name":"Alice"},
  {"id":"00456","name":"Bob"}
]

Save plain text with the .json extension

Use a plain-text editor or the browser beautifier. Paste your document, check for a valid result, and use Download to save formatted.json. Rename the file to the name expected by your application.

In an editor, select UTF-8 when choosing an encoding. Check that the saved filename is actually settings.json rather than settings.json.txt. A word processor document or a file containing HTML does not become JSON when its extension changes.

Validate syntax and then the contract

Syntax validation catches missing commas, unclosed brackets, invalid quotes and comments. A valid document can still have an incorrect property name or type, so application configuration and API payloads may also need schema validation.

For a new schema, the generator can provide a starting point from a sample. Review its required fields and additional-property rules before using it as a contract. A sample reveals observed data, not every valid case your application permits.

  • Use double quotes for names and text; single quotes are not strict JSON.
  • Avoid a comma after the last property or array item.
  • Write true, false and null in lowercase.
  • Escape a newline inside a string as \n rather than inserting a literal line break.
  • Keep comments in accompanying documentation unless the reader explicitly accepts JSONC or JSON5.

Put the example to work

Use your own sample, check the result, and copy or download it. The tool processes your data locally in your browser.

Create and download formatted JSON