HTML Formatter API
Pretty-print HTML with consistent indentation, or minify it (collapse whitespace, drop comments). <pre>, <textarea>, <script> and <style> contents are kept as written when minifying.
POST /api/v1/tools/html-formatterMCP html_formatterDeveloper ToolsBeautify messy HTML with clean indentation, or minify it by collapsing whitespace and removing comments while keeping pre, textarea and script content intact.
Input
Send these as a JSON object. Unknown fields are rejected.
- input
- The HTML. (string, required)
- mode
- format (pretty-print) or minify. (string, one of format, minify, default "format")
- indent
- Spaces per indent level when formatting. (integer, 1 to 8, default 2)
- tabs
- Indent with tabs instead of spaces when formatting. (boolean, default false)
- wrapLength
- Wrap lines longer than this many characters when formatting; 0 disables wrapping. (integer, 0 to 1000, default 0)
- wrapAttributes
- Attribute layout when formatting: auto, force (each on its own line), force-aligned or force-expand-multiline. (string, one of auto, force, force-aligned, force-expand-multiline, default "auto")
- removeComments
- When minifying, remove <!-- comments --> (conditional comments are kept). (boolean, default true)
- removeWhitespaceBetweenTags
- When minifying, remove all whitespace-only text between tags, not just next to block elements. Can join inline elements together. (boolean, default false)
curl https://pithlab.com/api/v1/tools/html-formatter \n -H "Authorization: Bearer $PITHLAB_KEY" \n -H "Content-Type: application/json" \n -d '{"input":"<ul><li><a href=\"/\">Home</a></li><li>About</li></ul>"}'Example response
{
"ok": true,
"result": {
"output": "<ul>\n <li><a href=\"/\">Home</a></li>\n <li>About</li>\n</ul>"
}
}