Fast, accurate HTML formatting for VS Code powered by a native Rust binary. The extension streams the editor buffer over stdin to htmlfmt and applies the formatted output back without writing temp files.
Highlights
High performance parsing via html5ever with a custom pretty serializer that respects HTML semantics.
One‑click setup: the extension downloads the correct binary automatically on first use, or you can select your own.
Works offline after first install; no telemetry, no network during formatting.
Status bar integration shows last format time and provides a quick “Format” action.
Commands
Rust HTML Formatter: Format Document
Rust HTML Formatter: Install/Select Binary
Settings
rustHtmlFormatter.binaryPath (string)
Absolute path to the htmlfmt binary. If empty, the extension searches common locations and will auto-download a prebuilt binary from the latest GitHub release when needed.
Search common locations (workspace target/*, ~/.cargo/bin, workspace .vscode/htmlfmt/) when binaryPath is not set.
Auto‑discovery order
Previously installed/selected path (persisted by the extension)
rustHtmlFormatter.binaryPath setting
HTMLFMT_PATH environment variable
~/.cargo/bin/htmlfmt(.exe) and ~/htmlfmt/htmlfmt(.exe)
<workspace>/.vscode/htmlfmt/htmlfmt(.exe)
<workspace>/target/{release,debug}/htmlfmt(.exe)
<extensionPath>/bin/htmlfmt(.exe) if packaged with the VSIX
Fallback to PATH
Status Bar
The extension adds a right‑aligned “HTMLFmt” status item:
Idle: HTMLFmt
Running: HTMLFmt …
Success: HTMLFmt 0.123s
Error: HTMLFmt ! (hover to see error)
Click the item to run “Format Document”.
Marketplace Details
Category: Formatters
Activation: on HTML files, on startup, and via commands
Icon: logo.png packaged with the extension
Troubleshooting
“htmlfmt not found”
Run the command “Rust HTML Formatter: Install/Select Binary” and choose a prebuilt binary or your locally built one. The extension will copy it to a managed location and remember it.
“Permission denied” on macOS/Linux
The extension sets executable bits automatically when installing. If needed: chmod +x the installed binary reported in the error message.
PATH differences
VS Code may use a different PATH than your shell. Using the built‑in installer avoids PATH issues altogether.
Conflicts with other formatters
Set the default formatter for HTML to “Rust HTML Formatter” in VS Code settings or via the “Format Document With…” picker.
License
MIT. See the repository for details and the formatter source.