JSON String
A sequence of zero or more Unicode characters, enclosed in double quotes ("). Strings in JSON represent textual data and must follow strict formatting rules for encoding and escaping.
In JSON, a string is a fundamental data type used to represent human-readable text, such as names, messages, or file paths. A valid JSON string:
- Must be enclosed in double quotes (
"
). - May contain Unicode characters (e.g., emojis or non-Latin scripts).
- Must escape special characters using the backslash (
\\
). - Cannot contain unescaped control characters such as newlines, tabs, or quotes.
Common escape sequences in JSON strings include:
\\
— Backslash\"
— Double quote\n
— New line\t
— Tab\b
— Backspace\f
— Form feed\uXXXX
— Unicode character (e.g.,\u2764
= ❤️)
Example of Escaping
{
"message": "He said, \"Hello, JSON!\" This is a valid string.",
"path": "C:\\Users\\JohnDoe",
"emoji": "I \u2764 JSON"
}
Improperly formatted strings are a common source of syntax errors in JSON. Always use a linter or JSON Validator tool to ensure correctness.
Strings in JSON cannot span multiple lines directly. If a line break is needed inside a string, use the \n
escape character.
In JavaScript and most programming languages that handle JSON, string encoding and decoding are handled automatically — but understanding these basics helps when manually writing or debugging JSON data.