A quick reference for JSON syntax, data types, escape sequences, and common patterns. Copy-paste ready.
"hello world"
"line one\nline two"
"path: C:\\Users\\file"42
3.14
-17
1.0e10true
falsenull[1, 2, 3]
["a", "b", "c"]
[{"id": 1}, {"id": 2}]
[]{
"name": "Alice",
"age": 30,
"active": true
}| Sequence | Character | Example |
|---|---|---|
\\n | Newline | "line1\nline2" |
\\t | Tab | "col1\tcol2" |
\\\\ | Backslash | "C:\\path" |
\\" | Double quote | "say \"hi\"" |
\\/ | Forward slash | "a\/b" |
\\b | Backspace | "back\bspace" |
\\f | Form feed | "form\ffeed" |
\\r | Carriage return | "line\r\n" |
\\uXXXX | Unicode | "\u00e9" (accent e) |
{
"database": {
"host": "localhost",
"port": 5432,
"name": "myapp",
"ssl": true
},
"logging": {
"level": "info",
"format": "json"
}
}{
"status": 200,
"data": {
"users": [
{ "id": 1, "name": "Alice", "email": "alice@example.com" },
{ "id": 2, "name": "Bob", "email": "bob@example.com" }
],
"total": 2,
"page": 1
},
"meta": {
"requestId": "abc-123",
"timestamp": "2024-01-15T10:30:00Z"
}
}{
"name": "my-app",
"version": "1.0.0",
"description": "A sample project",
"main": "index.js",
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"test": "vitest"
},
"dependencies": {
"next": "^15.0.0",
"react": "^19.0.0"
},
"devDependencies": {
"typescript": "^5.0.0"
}
}| Feature | JSON | YAML | XML |
|---|---|---|---|
| Readability | Good | Excellent | Moderate |
| Verbosity | Low | Very low | High |
| Comments | No | Yes (#) | Yes (<!-- -->) |
| Data types | 6 types | Rich (dates, etc.) | Strings only |
| Parsing speed | Fast | Moderate | Slow |
| Native in JS | Yes | No (library) | No (DOMParser) |
| Use case | APIs, configs | DevOps, configs | Enterprise, docs |
Got some JSON to validate or format?
Validate Your JSON →