Skip to content
| Marketplace
Sign in
Visual Studio Code>Formatters>Rust HTML FormatterNew to Visual Studio Code? Get it now.
Rust HTML Formatter

Rust HTML Formatter

phpont

|
4 installs
| (0) | Free
Format .html via a fast Rust binary (htmlfmt) over stdin/stdout.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Rust HTML Formatter (VS Code Extension)

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.
  • rustHtmlFormatter.autoDiscoverWorkspace (boolean, default true)
    • Search common locations (workspace target/*, ~/.cargo/bin, workspace .vscode/htmlfmt/) when binaryPath is not set.

Auto‑discovery order

  1. Previously installed/selected path (persisted by the extension)
  2. rustHtmlFormatter.binaryPath setting
  3. HTMLFMT_PATH environment variable
  4. ~/.cargo/bin/htmlfmt(.exe) and ~/htmlfmt/htmlfmt(.exe)
  5. <workspace>/.vscode/htmlfmt/htmlfmt(.exe)
  6. <workspace>/target/{release,debug}/htmlfmt(.exe)
  7. <extensionPath>/bin/htmlfmt(.exe) if packaged with the VSIX
  8. 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.

Source & Issues

  • Repository: https://github.com/phpont/html-formatter-rust
  • Report issues: https://github.com/phpont/html-formatter-rust/issues
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft