HTML formatter
Re-indent HTML so the nesting is easy to read, leaving pre, textarea, script and style content untouched.
Input
Result
Fill in the input and press Run.
Your input is processed in memory and then discarded. It is not stored or logged. Even so, don't paste live passwords or keys into any online tool.
Use it from code or an agent
curl -s https://setget.net/v1/tools/html-format \
-H 'Content-Type: application/json' \
-d '{"input":{"text":"<div><p>Hello <b>world</b></p><ul><li>One<li>Two</ul></div>"}}'
import json, urllib.request
body = {'input': {'text': '<div><p>Hello <b>world</b></p><ul><li>One<li>Two</ul></div>'}}
request = urllib.request.Request("https://setget.net/v1/tools/html-format", json.dumps(body).encode(),
{"Content-Type": "application/json"})
print(json.load(urllib.request.urlopen(request))["result"])
const response = await fetch("https://setget.net/v1/tools/html-format", {
method: "POST",
headers: {"Content-Type": "application/json"},
body: JSON.stringify({"input":{"text":"<div><p>Hello <b>world</b></p><ul><li>One<li>Two</ul></div>"}}),
});
console.log((await response.json()).result);
Tool: run_tool
Arguments:
{
"slug": "html-format",
"input": {
"text": "<div><p>Hello <b>world</b></p><ul><li>One<li>Two</ul></div>"
}
}
{
"input": {
"text": "<div><p>Hello <b>world</b></p><ul><li>One<li>Two</ul></div>"
}
}
Endpoint: POST /v1/tools/html-format. Over MCP: run_tool with slug: "html-format".
Machine-readable: input schema, Markdown. Connect an agent.
Inputs
| Name | Type | Required | What it does |
|---|---|---|---|
text |
string | yes | The HTML to format. |
indent |
integer | no | Spaces per indentation level. Default: 2. From 1 to 8. |
Examples
Input
{
"text": "<div><p>Hello <b>world</b></p><ul><li>One<li>Two</ul></div>"
}Result
{
"text": "<div>\n <p>Hello <b>world</b></p>\n <ul>\n <li>One\n <li>Two\n </ul>\n</div>"
}Preformatted text is not touched
Input
{
"text": "<!DOCTYPE html><html><body><pre> a\n b</pre><br></body></html>",
"indent": 4
}Result
{
"text": "<!DOCTYPE html>\n<html>\n <body>\n <pre> a\n b</pre>\n <br>\n </body>\n</html>"
}Questions
- Does it repair broken HTML?
- No. Tags are written back as they were. Missing end tags are not added, and a stray end tag is dropped.
- Why are some tags kept on one line?
- Inline elements such as a, b and span stay in the flow of the text around them, because moving them to new lines could add visible spaces.
- Can the page look different afterwards?
- Rarely. Runs of spaces and line breaks between tags are normalised, which only matters where CSS makes white space significant outside pre.
Related tools
- HTML minifierShrink HTML by removing comments and needless white space, without touching pre, textarea, script or style.
html-minify - XML formatterPretty-print XML with consistent indentation, or collapse it to a single line.
xml-format - CSS formatterPretty-print minified or messy CSS with one declaration per line and nested @media blocks indented.
css-format - HTML to plain textExtract readable plain text from HTML: headings, paragraphs, list bullets and table rows, without scripts or menus.
html-to-text - .gitignore testerCheck which paths a .gitignore file ignores and which line decided each one, using real Git matching rules.
gitignore-test - Cache-Control explainerExplain a Cache-Control header directive by directive and how browsers and CDNs will treat the response.
cache-control-explain