JSON Stringify ASCII Text

Node.js CI

Convert ASCII text to JSON String by escaping appropropriate characters.

Note: Since ASCII characters are a subset of Unicode characters and none have u <hex> <hex> <hex> <hex> format, this utility doesn't handle characters like Emoji though they are covered in JSON spec.

Why?

To quickly convert ASCII text, like contents of Base64 encoded files, to JSON string format. E.g.: X.509 public certificates of PEM format.

BEWARE

Do no trust external websites with any private or confidential or secret data or information.

What is a JSON String?

Excerpt from Introducing JSON:

A string is a sequence of zero or more Unicode characters, wrapped in double quotes, using backslash escapes. A character is represented as a single character string. A string is very much like a C or Java string.

JSON backslash escape characters

  • Quotation mark: "
  • Reverse solidus: \
  • Solidus: /
  • Backspace: b
  • Formfeed: f
  • Linefeed: n
  • Carriage return: r
  • Horizontal tab: t
  • 4 hex digits (unicode characters beyond ASCII): u hex hex hex hex

Resources