prettier-compare
Purpose
Use packages/prettier-compare/ to inspect any differences between Biome and Prettier formatting (including IR output) before shipping formatter changes.
Prerequisites
- Run every command from the repository root so relative paths resolve correctly.
- Use
bun(the CLI is a Bun script) and ensure dependencies have been installed. - Always pass
--rebuildso the Biome WASM bundle matches your current Rust changes.
Common workflows
Snippets passed as CLI args:
bun packages/prettier-compare/bin/prettier-compare.js --rebuild 'const x={a:1,b:2}'
Force a language (useful when the tool cannot infer it from a filename):
bun packages/prettier-compare/bin/prettier-compare.js --rebuild -l ts 'const x: number = 1'
Compare files on disk:
bun packages/prettier-compare/bin/prettier-compare.js --rebuild -f src/example.tsx
Read from stdin (great for piping editor selections):
echo 'const x = 1' | bun packages/prettier-compare/bin/prettier-compare.js --rebuild -l js
Tips
- Use
-l/--languagewhen formatting code without an extension so both formatters pick the correct parser. - Use
-f/--filefor large samples or snapshot tests so you can iterate directly on project fixtures. - Reference
packages/prettier-compare/README.mdfor deeper CLI details; mirror any updates here, keeping the hard requirement that commands include--rebuild. - Use single quotes for code snippets passed as CLI arguments to avoid shell interpretation issues.
- "\n" does not get escaped into a newline when passed as a CLI argument. You should write a literal newline or use a file instead.
More from biomejs/biome
biome-developer
General development best practices and common gotchas when working on Biome. Use for avoiding common mistakes, understanding Biome-specific patterns (AST, syntax nodes, string extraction, embedded languages), and learning technical tips.
133parser-development
Guide for implementing parsers with error recovery for new languages in Biome. Use when adding parsing support for a new language, implementing error recovery in a parser, or writing grammar definitions in .ungram format for JavaScript, CSS, JSON, HTML, GraphQL, or other languages.
80lint-rule-development
Step-by-step guide for creating and implementing lint rules in Biome's analyzer. Use when implementing rules like noVar, useConst, or any custom lint/assist rule, adding code actions to fix diagnostics, implementing semantic analysis for binding references, or adding configurable options to rules.
74formatter-development
Guide for implementing formatting rules using Biome's IR-based formatter infrastructure. Use when implementing formatting for new syntax nodes, handling comments in formatted output, writing or debugging formatter snapshot tests, diagnosing idempotency failures, or comparing Biome's formatting against Prettier for JavaScript, CSS, JSON, HTML, Markdown, or other languages.
71testing-codegen
Guide for testing workflows and code generation commands in Biome. Use when running snapshot tests for lint rules, managing insta snapshots, or regenerating analyzer/parser/formatter code after changes.
69type-inference
Guide for working with Biome's module graph and type inference system. Use when implementing type-aware lint rules, understanding type resolution, working on the module graph infrastructure, or implementing type inference for new features.
67