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 mode | What it normalises |
|---|---|
| Python | Indentation to 4 spaces per block based on colons and dedents; trailing whitespace |
| PHP | Brace-based indentation, spacing around operators, one statement per line |
| Ruby | Indentation by do/end, def/end, if/end and class/module blocks |
| Go | gofmt-style tabs and brace placement (opening brace on the same line) |
| Generic | Brace-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 <example></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
| Language | Convention |
|---|---|
| Python | 4 spaces (PEP 8); indentation is syntax |
| PHP | 4 spaces (PSR-12); braces on their own line for classes and functions |
| Ruby | 2 spaces |
| Go | Tabs, enforced by gofmt |
| JavaScript / TypeScript | 2 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.