# HTML formatter

Re-indent HTML so the nesting is easy to read, leaving pre, textarea, script and style content untouched.

- Endpoint: `POST https://setget.net/v1/tools/html-format` with JSON `{"input": {...}}`
- MCP: `run_tool` with `slug` = `html-format`
- Page: https://setget.net/tools/html-format

## Inputs

- `text` (required, string): The HTML to format.
- `indent` (optional, integer, default `2`, range 1..8): Spaces per indentation level.

## Example 1

```json
{"input":{"text":"<div><p>Hello <b>world</b></p><ul><li>One<li>Two</ul></div>"}}
```

Result:

```json
{"text":"<div>\n  <p>Hello <b>world</b></p>\n  <ul>\n    <li>One\n    <li>Two\n  </ul>\n</div>"}
```

## Example 2: Preformatted text is not touched

```json
{"input":{"text":"<!DOCTYPE html><html><body><pre>  a\n  b</pre><br></body></html>","indent":4}}
```

Result:

```json
{"text":"<!DOCTYPE html>\n<html>\n    <body>\n        <pre>  a\n  b</pre>\n        <br>\n    </body>\n</html>"}
```

**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.
