How to Work with JSON Files
Open, create, read, edit, and convert JSON files — complete guide with examples and a free online formatter.
Quick Start
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.
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.
Convert and download
Click Convert. The result appears instantly. Copy to clipboard or click Download to save the file.
Input Methods
Copy-paste JSON directly into the textarea. Works for any size up to ~50 MB.
Click "Import File" to open a file picker. Supports .json, .txt, .jsonl.
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
DelimiterCharacter that separates values. Comma is the CSV standard. Use semicolon for European locales, tab for TSV.
Include HeadersWhen on, the first row of CSV output contains column names taken from JSON keys. Uncheck for data-only output.
Force QuotesWraps every value in double quotes. Useful when values may contain the delimiter character.
Remove Line BreaksStrips \n and \r inside string values. Prevents multi-line cells in spreadsheet apps.
TransposeSwaps rows and columns (pivot). Useful for turning wide JSON objects into tall CSV tables.
Disable Array JoinBy 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.
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.
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" }
]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.14No quotes needed. Integers and floats both work
booleantrue / falseLowercase only — True and False are invalid
nullnullRepresents 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
Edit values between the quotes or after the colon
Add a comma after every item except the last in a list
Validate in the formatter below before saving
Use single quotes — JSON requires double quotes everywhere
Leave trailing commas — JSON parsers reject them
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
Use a literal newline inside a string value
Use backtick template literals — JSON is not JavaScript
Use \n escape sequence for newlines
Use string concatenation in your code before serializing to JSON
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