Oxfmt
High-performance formatter (~30x faster than Prettier) for JavaScript/TypeScript/JSON/CSS and more.
Installation
pnpm add -D oxfmt
Usage
# Format all files
pnpm oxfmt --write .
# Check formatting without writing
pnpm oxfmt --check .
# Initialize config
pnpm oxfmt --init
Configuration
Create .oxfmtrc.json:
{
"$schema": "./node_modules/oxfmt/configuration_schema.json",
"semi": false,
"singleQuote": true,
"trailingComma": "all",
"printWidth": 80
}
Prettier-compatible options:
semi- Add semicolons (default: true)singleQuote- Use single quotes (default: false)trailingComma- "all" | "es5" | "none"printWidth- Line width limit (default: 100)tabWidth- Spaces per indent (default: 2)useTabs- Use tabs (default: false)
Oxfmt-specific:
experimentalSortImports- Sort importsexperimentalTailwindcss- Sort Tailwind classesinsertFinalNewline- Add final newline (default: true)
Migration from Prettier
Oxfmt automatically reads .prettierrc. To migrate:
- Install oxfmt:
pnpm add -D oxfmt - Rename
.prettierrcto.oxfmtrc.json - Add
"$schema": "./node_modules/oxfmt/configuration_schema.json" - Remove
prettierfrom devDependencies - Update scripts:
"format": "oxfmt --write"
Package.json Scripts
{
"scripts": {
"format": "oxfmt --write .",
"format:check": "oxfmt --check ."
}
}