Skip to content

compactJSON

compactJSON(json, options?, indent?) → string · JSON

Compact a JSON string by removing all unnecessary whitespace.

  • json (required): JSON string to compact

  • options (optional): formatting options

  • indent (optional): indentation level

bash
echo '{"data": {"name": "Alice", "age": 30}}' | utlx -e 'compactJSON(renderJson($input))'
# {"name":"Alice","age":30}
utlx
// See Chapter 24 for JSON processing.
{
  minified: compactJSON(renderJson($input))
}

Released under AGPL-3.0.