Configuration
Oxfmt works out of the box, but most teams commit a configuration file to keep formatting consistent across local runs, editors, and CI.
This page focuses on project configuration: formatting options, ignore patterns, and experimental features.
Create a config file
To generate a starter config in the current directory:
oxfmt --initOxfmt automatically looks for .oxfmtrc.json or .oxfmtrc.jsonc starting from the current directory and walking up the tree. You can also pass a config explicitly:
oxfmt -c path/to/yourconfig.jsonA minimal configuration looks like this:
{
"$schema": "./node_modules/oxfmt/configuration_schema.json",
"printWidth": 80
}Configuration file format
A configuration file is a JSON object. The most common top-level fields are:
printWidth: Line width limit (default: 100)tabWidth: Spaces per indentation level (default: 2)useTabs: Use tabs instead of spaces (default: false)semi: Add semicolons (default: true)singleQuote: Use single quotes (default: false)trailingComma: Trailing commas in multi-line structures (default: "all")ignorePatterns: Glob patterns to exclude from formattingexperimentalSortImports: Configure import sorting (disabled by default)experimentalSortPackageJson: Configure package.json sorting (enabled by default)experimentalTailwindcss: Configure Tailwind class sorting (disabled by default)
For a complete list of fields, see the Config file reference.
JSON schema
Add a $schema field for editor validation and autocomplete:
{
"$schema": "./node_modules/oxfmt/configuration_schema.json"
}.editorconfig
Oxfmt reads these .editorconfig properties:
end_of_line→endOfLineindent_style→useTabsindent_size→tabWidthmax_line_length→printWidthinsert_final_newline→insertFinalNewline
Both root section and glob-based overrides are supported.
[*]
indent_size = 4
[*.{js,ts}]
indent_size = 2Oxfmt uses only the nearest .editorconfig from the current directory:
root = trueis not respected- Nested
.editorconfigfiles are not merged
Precedence
Options are applied in order (lowest to highest priority):
- Defaults
.oxfmtrc.json(c)root options.oxfmtrc.json(c)overridesoptions- fallback to options supported by
.editorconfigfor unset fields
Oxfmt-specific options
insertFinalNewline
Controls whether a final newline is added to formatted files. Defaults to true.
This is a frequently requested Prettier feature, as some environments (e.g., Salesforce) strip trailing newlines.
printWidth
Oxfmt defaults to printWidth: 100 (Prettier uses 80). Reasons:
- TypeScript code is longer due to type annotations
- Import statements often have many specifiers
- Modern screens are wider
- Fewer line breaks mean fewer LLM tokens
To match Prettier's default:
{
"printWidth": 80
}Next steps
- Ignore files: Ignore files and patterns,
.gitignoreand.prettierignoreworkflows. - Inline ignore comments: Inline suppressions for specific code.
- Config file reference: Full schema and field documentation.
- CLI reference: Complete list of flags.
