HTML Formatter

Prettify or minify HTML code for readability or production deployment

0 characters

API Usage

Integrate HTML formatting into your applications with our REST API.

Endpoint

POST /api/html-formatter

Request Body

{
  "html": "<div><h1>Hello</h1></div>",
  "mode": "prettify",           // or "minify"
  "options": {
    "indentSize": 2,            // spaces per indent (prettify)
    "removeComments": false,    // remove HTML comments
    "sortAttributes": false     // sort attributes alphabetically
  }
}

cURL Example

curl -X POST https://toolteeno.com/api/html-formatter \
  -H "Content-Type: application/json" \
  -d '{
    "html": "<div><h1>Hello World</h1><p>Test</p></div>",
    "mode": "prettify",
    "options": {"indentSize": 2}
  }'

JavaScript Example

const response = await fetch('/api/html-formatter', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    html: '<div><h1>Hello</h1></div>',
    mode: 'minify',
    options: { removeComments: true }
  })
});

const data = await response.json();
console.log(data.output); // Minified HTML

Python Example

import requests

response = requests.post('https://toolteeno.com/api/html-formatter', json={
    'html': '<div><h1>Hello World</h1></div>',
    'mode': 'prettify',
    'options': {'indentSize': 4, 'removeComments': True}
})

data = response.json()
print(data['output'])  # Prettified HTML

Common Use Cases

  • Format messy HTML from WYSIWYG editors for better readability
  • Minify HTML for production to reduce file size and improve load times
  • Clean up generated HTML from templates or build tools
  • Standardize HTML formatting across development teams
  • Remove comments and unnecessary whitespace before deployment
  • Prepare HTML for version control with consistent formatting