jq Filters and Transformations/HTML-escape a string

Escape special HTML characters.

Section: Encoding and Recursion

HTML-escape a string

bash
bash
echo '"<b>hello</b>"' | jq -r '@html'
Explanation

Useful for templating and safe output.

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 Encoding and Recursion
JSON-encode raw text
Turn raw text into a valid JSON string.
OpenIn sheetbashsame section
Shell-escape a string
Produce a shell-safe quoted string.
OpenIn sheetbashsame section
Find all keys recursively
Emit every key in nested objects.
OpenIn sheetbashsame section
Find all numbers recursively
Emit every number in a document.
OpenIn sheetbashsame section
Logical AND
Filter items that satisfy two conditions.
OpenIn sheetbash1 tag match
Test regex match
Return true if a string matches a pattern.
OpenIn sheetbash1 tag match