Home/Developer Tools/Multi-Language Formatter & HTML Generator
🌐

Multi-Language Formatter & HTML Generator

FREE

Re-indent Python, PHP, Ruby, Go; build escaped HTML elements

Free · No sign-up required
Loading...

What this tool does

Two utilities in one page. The formatter re-indents code in Python, PHP, Ruby, Go or a generic C-style language, fixing inconsistent indentation and brace placement so a pasted snippet is readable. The HTML generator builds an element from a tag name, attributes and inner content — handy for producing a correctly escaped snippet without hand-typing brackets and quotes. Both run in your browser.

The formatter

Language modeWhat it normalises
PythonIndentation to 4 spaces per block based on colons and dedents; trailing whitespace
PHPBrace-based indentation, spacing around operators, one statement per line
RubyIndentation by do/end, def/end, if/end and class/module blocks
Gogofmt-style tabs and brace placement (opening brace on the same line)
GenericBrace-based indentation for C, Java, C#, JavaScript-like syntax

The formatter works on structure — braces, keywords and indentation — rather than a full parse, so it is fast and tolerant of incomplete snippets. It will not catch syntax errors or apply every rule of a language's official style guide; for that, use the language's own tool (black, php-cs-fixer, rubocop, gofmt).

The HTML generator

Tag: a Attributes: href="https://example.com" class="btn" target="_blank" Content: Visit <example> Output: <a href="https://example.com" class="btn" target="_blank">Visit &lt;example&gt;</a>
  • Inner content is HTML-escaped automatically, so text containing < or & is safe to insert.
  • Void elements (img, br, input, meta) are emitted without a closing tag.
  • Attribute values are quoted; quotes inside them are escaped.

Common uses

  • Cleaning up code copied from a chat, an email or a PDF where indentation was lost.
  • Reformatting a snippet in a language you do not have an environment set up for.
  • Preparing examples for documentation in several languages with consistent style.
  • Producing a single correctly escaped HTML element for a CMS field, an email or a README.
  • Teaching — showing what properly indented Python or Go looks like.

Indentation conventions by language

LanguageConvention
Python4 spaces (PEP 8); indentation is syntax
PHP4 spaces (PSR-12); braces on their own line for classes and functions
Ruby2 spaces
GoTabs, enforced by gofmt
JavaScript / TypeScript2 spaces most common
Java / C#4 spaces

The formatter applies each language's convention automatically. Mixed tabs and spaces — a frequent cause of Python errors — are normalised.

Frequently asked questions

Will the formatter change what my code does?

It changes whitespace and line structure only. In Python, where indentation is meaningful, it reconstructs blocks from colons and dedent keywords; check the result on complex nesting.

Does it support JavaScript or CSS?

Use the dedicated JavaScript Tools and CSS Formatter pages, which handle those languages more precisely. The generic mode works for JavaScript-like syntax in a pinch.

Can the HTML generator make nested structures?

One element at a time. Generate the inner element, paste its output as the content of the outer one.

Why does Go output use tabs?

Because gofmt does, and Go code with spaces is considered incorrectly formatted by the community's tooling.

Can I set the indent size?

Not here — each language uses its standard. Editors and official formatters offer configuration.

Is my code uploaded?

No. Everything runs in your browser.

More tools in this category

📋
JSON Tools
View tree, format, validate and minify JSON
📄
YAML Beautifier & Validator
Format YAML and find the line that breaks it
📋
XML Tools
Beautify, validate and convert XML to JSON
🗃
SQL Formatter & Minifier
Lay out SQL clause by clause, or collapse it to one line
📝
Markdown Tools
Preview Markdown, convert to HTML and generate tables
🔑
JWT Encoder & Decoder
Decode a JWT's header and payload, or sign one with HS256