JSON Escaping and Encoding/Escape control characters

Use `\n`, `\r`, and `\t` for control characters.

Section: Escaping basics

Escape control characters

json
json
{
  "log": "first line\nsecond line\r\nthird line"
}
Explanation

Control characters must be escaped when they appear inside a JSON string.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Escaping basics
Escape a backslash
Represent a literal backslash inside a string.
OpenIn sheetjsonsame section
Escape a forward slash if needed
Escaping `/` is optional in JSON.
OpenIn sheetjsonsame section
JSON string containing JSON
Sometimes one field stores another JSON document as a string.
OpenIn sheetjson2 tag match
Prefer UTF-8 encoded JSON
UTF-8 is the de facto standard for JSON payloads.
OpenIn sheettext1 tag match
Decode embedded JSON with jq
Parse a JSON string field into structured data.
OpenIn sheetbash1 tag match
Encode structured data as a JSON string
Turn a value into a JSON-encoded string.
OpenIn sheetbash1 tag match