How to Work with JSON Files

Open, create, read, edit, and convert JSON files — complete guide with examples and a free online formatter.

12 sections·8 min read

Quick Start

1

Paste or upload your data

Go to any tool (e.g. JSON to CSV). Paste your JSON directly into the input area, or click Import File to upload.

2

Adjust settings if needed

The settings panel lets you change delimiter, toggle headers, enable quoting, and more. Defaults work for most cases — you can often skip this step.

3

Convert and download

Click Convert. The result appears instantly. Copy to clipboard or click Download to save the file.

Input Methods

Paste

Copy-paste JSON directly into the textarea. Works for any size up to ~50 MB.

File Upload

Click "Import File" to open a file picker. Supports .json, .txt, .jsonl.

Fetch URL

Switch to the "Enter URL" tab and enter any public API endpoint that returns JSON.

JSON Lines supported. Switch to the "JSON Lines" tab if your input has one JSON object per line (common in log files and NDJSON exports).

Settings

Delimiter

Character that separates values. Comma is the CSV standard. Use semicolon for European locales, tab for TSV.

Include Headers

When on, the first row of CSV output contains column names taken from JSON keys. Uncheck for data-only output.

Force Quotes

Wraps every value in double quotes. Useful when values may contain the delimiter character.

Remove Line Breaks

Strips \n and \r inside string values. Prevents multi-line cells in spreadsheet apps.

Transpose

Swaps rows and columns (pivot). Useful for turning wide JSON objects into tall CSV tables.

Disable Array Join

By default, arrays are joined as semicolon-separated strings. Enable this to keep them as raw JSON.

Examples

JSON array → CSV

Most common case — an array of uniform objects.

Input JSON

[
  { "name": "Alice", "age": 30, "city": "NYC" },
  { "name": "Bob",   "age": 25, "city": "London" }
]

Output CSV

name,age,city
Alice,30,NYC
Bob,25,London

CSV → JSON

Numbers and booleans are auto-detected.

Input CSV

product,price,in_stock
Laptop,999.99,true
Book,19.99,false

Output JSON

[
  { "product": "Laptop", "price": 999.99, "in_stock": true },
  { "product": "Book",   "price": 19.99,  "in_stock": false }
]

JSON → TypeScript interface

Use JSON to TypeScript to generate typed interfaces from any JSON object.

Input JSON

{
  "id": 1,
  "name": "Alice",
  "active": true
}

Output TypeScript

export interface Root {
  id:     number;
  name:   string;
  active: boolean;
}

Compare two JSON objects

Use JSON Compare — paste both objects, click Compare. Differences are highlighted inline with a detailed diff list below.

Best Practices

Consistent JSON structure

For best CSV output, all objects in your array should have the same keys. Missing keys produce empty cells.

UTF-8 encoding

Save or export your source files in UTF-8. Other encodings may corrupt accented characters during conversion.

Large files (> 10 MB)

Split large files into smaller batches. All processing runs in your browser, so very large files may be slow on low-end devices.

CSV with delimiters in values

Enable "Force Quotes" if your string values might contain commas or your chosen delimiter character.

Type-safe conversions

CSV → JSON detects numbers and booleans automatically. Always verify the output before using it in production pipelines.

Your data stays private

All conversion happens in your browser. Nothing is uploaded to any server — safe for sensitive or proprietary data.

How to Open a JSON File

A JSON file is plain text, so any text editor can open it. The right tool depends on what you want to do with it.

Text editors

  • VS Code — best overall, syntax highlighting + collapse
  • Notepad++ — lightweight, Windows
  • Sublime Text — fast for large files
  • Notepad — works, no highlighting

Browsers

  • Chrome / Firefox / Edge — drag the .json file onto a tab
  • Install a JSON Viewer extension for folding and color
  • Right-click → Open with → choose your browser

Spreadsheet apps

  • Excel / Google Sheets — use Data → Get External Data or our JSON to Excel tool
  • Helpful when the JSON is an array of flat objects

Command line

  • cat file.json | python -m json.tool
  • jq . file.json (install jq for color + filtering)
  • node -e "console.log(require('./file.json'))"

Tip: If your .json file opens as gibberish in Excel, use our JSON to CSV tool first, then open the CSV in Excel — it renders cleanly every time.

How to Create a JSON File

Creating a JSON file takes under a minute. The format has three rules: keys are strings in double quotes, values are one of six types, and commas separate items.

1

Open any text editor

VS Code, Notepad++, or even plain Notepad. Create a new file and save it with a .json extension — e.g. data.json.

2

Write valid JSON

Start with { for an object or [ for an array. Use the examples below as a starting point.

Single object

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

Array of objects

[
  { "id": 1, "name": "Alice" },
  { "id": 2, "name": "Bob" }
]
3

Validate and save

Paste your JSON into the View & Format JSON section below to check for syntax errors, then save the file.

JSON value types

string"hello"

Always double quotes — single quotes are invalid JSON

number42 / 3.14

No quotes needed. Integers and floats both work

booleantrue / false

Lowercase only — True and False are invalid

nullnull

Represents an empty or unknown value

array[1, "a", true]

Ordered list, mix any types

object{"key": "val"}

Key-value pairs, keys must be strings

How to Read & Edit JSON Files

Reading JSON means parsing its structure. Editing means modifying keys or values without breaking the syntax. Both are straightforward once you know the common patterns.

Reading JSON — what to look for

Root type

Does it start with { (object) or [ (array)? Arrays contain multiple records; objects are single records.

Nesting depth

Objects inside objects are nested. Keys use dot notation: user.address.city. Deep nesting is normal in API responses.

Data types

Quoted values are strings. Unquoted numbers/true/false/null are their native types. Arrays are enclosed in [ ].

Editing JSON safely

DO

Edit values between the quotes or after the colon

DO

Add a comma after every item except the last in a list

DO

Validate in the formatter below before saving

DON'T

Use single quotes — JSON requires double quotes everywhere

DON'T

Leave trailing commas — JSON parsers reject them

DON'T

Add comments — JSON has no comment syntax

Reading nested JSON in Python

import json

with open('data.json') as f:
    data = json.load(f)

# Access a nested value
city = data['user']['address']['city']

# Iterate an array
for item in data['items']:
    print(item['name'])

How to Add Comments in JSON

JSON does not support comments natively. The JSON spec (RFC 8259) intentionally omits comment syntax to keep parsing simple and interoperable. Adding // or /* */ will cause a parse error in any standard JSON parser.

Workarounds

"_comment" key

Add a string field with a descriptive key like "_comment". Most parsers ignore unknown keys. Safest and most portable approach for data files.

{
  "_comment": "User record",
  "id": 1,
  "name": "Alice"
}

JSONC format

JSON with Comments (.jsonc) is supported by VS Code for config files like tsconfig.json. Allows // and /* */ syntax but is not valid standard JSON.

// tsconfig.jsonc
{
  // Enable strict mode
  "strict": true
}

JSON5

A superset of JSON that adds comment support, trailing commas, and unquoted keys. Used by some config tools and build systems.

{
  // JSON5 comment
  name: "Alice", // trailing comma OK
}

For production data files, the "_comment" key approach is safest and most portable. For config files such as tsconfig.json or VS Code settings, JSONC is the standard choice.

Multiline Strings in JSON

JSON does not support multiline strings natively. A string value must be written on a single line — line breaks inside string values cause a parse error.

What to do and what to avoid

DON'T

Use a literal newline inside a string value

DON'T

Use backtick template literals — JSON is not JavaScript

DO

Use \n escape sequence for newlines

DO

Use string concatenation in your code before serializing to JSON

DO

Use an array of strings for long multiline content

Three approaches

Escape sequences

{
  "message": "Line one\nLine two\nLine three"
}

\n = newline, \t = tab, \\ = backslash

Array of lines

{
  "lines": [
    "Line one",
    "Line two",
    "Line three"
  ]
}

Best for content that will be joined with \n in code.

Minified (what JSON stores)

{"message":"Line one\nLine two\nLine three"}

JSON always stores the escaped version — the newlines are only real when parsed.

View & Format JSON

Paste any JSON below to instantly pretty-print it with indentation, or minify it to a single line. The formatter also validates your JSON and highlights errors.

Input JSON

Output

All Tools

JSON to CSVExport JSON arrays as CSV files
CSV to JSONParse CSV into JSON objects
JSON to ExcelDownload as XLSX workbook
Excel to JSONConvert XLSX files to JSON arrays
XML to CSVConvert XML to spreadsheet format
XML to ExcelExport XML as XLSX workbook
JSON to TableInteractive data table viewer
JSON to ParquetConvert JSON to Parquet-ready CSV
JSON to XMLSerialize JSON as XML markup
XML to JSONParse XML documents to JSON
JSON to YAMLConvert JSON to YAML format
YAML to JSONParse YAML back to JSON
JSON to JSONLConvert JSON array to JSON Lines
JSONL to JSONParse JSON Lines into a JSON array
JSON to SQLGenerate INSERT statements
JSON to GeoJSONConvert location data to GeoJSON
JSON to SRTConvert JSON subtitles to SRT format
JSON to Base64Encode JSON as a Base64 string
Base64 to JSONDecode Base64 back to JSON
JSON FormatterFormat, validate, and minify JSON
JSON CompareDiff two JSON objects side by side
JSON to SchemaGenerate JSON Schema (draft-07)
JSON to StringStringify and escape JSON
String to JSONParse stringified JSON safely
JSON to ObjectParse JSON and generate accessor code
JSON to TextConvert JSON to plain text output
JSON to PNGRender JSON as a syntax-highlighted image
JSON to PDFRender JSON as a formatted PDF
JSON to WordGenerate a Word .docx document
JSON to MarkdownRender as Markdown tables and code blocks
JSON to HTMLRender JSON as an HTML table
Markdown to JSONParse Markdown into a JSON block array
HTML to JSONParse HTML structure into a JSON tree
PDF to JSONExtract PDF text content as JSON
Image to JSONExtract EXIF metadata from photos
TXT to JSONConvert plain text to JSON
JSON to GraphQLGenerate GraphQL schema types
JSON to ProtobufGenerate proto3 message schema
JSON to TypeScriptGenerate TypeScript interfaces
JSON to JavaGenerate Java POJO classes
JSON to C#Generate C# model classes
JSON to PythonGenerate Python dataclasses
JSON to GoGenerate Go struct definitions
JSON to CGenerate C struct definitions
JSON to DartGenerate Dart / Flutter model classes
JSON to RustGenerate Rust struct definitions
JSON to POJOGenerate Java POJO with getters/setters
Parquet to JSONConvert Parquet CSV export to JSON