mcpField
O
oxfmt

oxfmt

github.com/delexwDevelopment241 installsUpdated 31w ago
Repository

About oxfmt

oxfmt is a Prettier-compatible formatter for the JavaScript ecosystem, intended for developers and teams that need consistent code formatting. It handles a broad range of code and document formats and offers a CLI, Node.js API, LSP support, and configuration migration.

Key features

  1. 01Formats many code and document types
  2. 02Migrates Prettier configuration
  3. 03Provides check and write modes
  4. 04Supports LSP editor integration
  5. 05Offers a Node.js API

Use cases

  1. 01Format a JavaScript or TypeScript project
  2. 02Migrate Prettier configuration to oxfmt
  3. 03Check formatting consistency in CI

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/delexw/claude-code-misc --skill oxfmt

After installing, type/oxfmtin Claude Code to confirm it loaded.

Details

From the project README

Oxfmt — The Oxc Formatter

Oxfmt is a Prettier-compatible formatter for the JavaScript ecosystem. It currently passes ~95% of Prettier's JS/TS test suite. It formats JavaScript, JSX, TypeScript, TSX, JSON, JSONC, JSON5, YAML, TOML, HTML, Angular, Vue, CSS, SCSS, Less, Markdown, MDX, GraphQL, Ember, and Handlebars.

When to use oxfmt

  • After modifying code in a project that has oxfmt installed
  • Setting up formatting in a new JS/TS project
  • Migrating from Prettier to oxfmt
  • Configuring formatting rules, editor integration, or CI checks

Quick reference

Installation
# Pick your package manager
npm add -D oxfmt
pnpm add -D oxfmt
yarn add -D oxfmt
bun add -D oxfmt

Add scripts to package.json:

{
  "scripts": {
    "fmt": "oxfmt",
    "fmt:check": "oxfmt --check"
  }
}

Running oxfmt with no arguments formats the current directory (like prettier --write .).

CLI flags
FlagPurpose
--checkCheck formatting without writing (exit 1 if unformatted)
--list-differentList files that would change
--writeFormat and write in place (default)
--initCreate .oxfmtrc.json with defaults
--migrate=prettierConvert .prettierrc to .oxfmtrc.json
--migrate=biomeConvert Biome config to .oxfmtrc.json
-c PATHUse a specific config file
--ignore-path PATHCustom ignore file (repeatable)
--with-node-modulesInclude node_modules/ (skipped by default)
--no-error-on-unmatched-patternDon't fail on unmatched globs
--stdin-filepath PATHFormat stdin, using PATH to infer parser
--threads NThread count (set to 1 for single core)
--lspStart the LSP server (used by editors)

CLI does not support formatting options as flags (e.g., no --no-semi). Use the config file instead — this keeps formatting consistent across CLI, editors, and CI.

Configuration

Oxfmt looks for .oxfmtrc.json or .oxfmtrc.jsonc starting from the current directory, walking up.

Generate a starter config:

oxfmt --init
Core options
{
  "$schema": "./node_modules/oxfmt/configuration_schema.json",
  "printWidth": 100,       // Line width limit (default: 100, Prettier default is 80)
  "tabWidth": 2,           // Spaces per indent level
  "useTabs": false,        // Tabs vs spaces
  "semi": true,            // Semicolons
  "singleQuote": false,    // Quote style
  "trailingComma": "all",  // Trailing commas in multi-line
  "insertFinalNewline": true
}

Note: oxfmt defaults printWidth to 100, while Prettier defaults to 80. If migrating, decide which you prefer.

Per-file overrides
{
  "printWidth": 100,
  "overrides": [
    {
      "files": ["*.test.js", "*.spec.ts"],
      "options": { "printWidth": 120 }
    },
    {
      "files": ["*.json"],
      "excludeFiles": ["package.json"],
      "options": { "tabWidth": 4 }
    }
  ]
}
Built-in features

These are disabled by default but can be enabled in the config:

  • sortImports — Sorts import statements
  • sortTailwindcss — Sorts Tailwind CSS classes
  • sortPackageJson — Sorts package.json fields (enabled by default)
Ignore patterns

Add ignorePatterns in the config file, or use a .oxfmtignore / .prettierignore file:

{
  "ignorePatterns": ["dist/", "coverage/", "*.min.js"]
}
.editorconfig support

Oxfmt reads these .editorconfig properties (nearest file only, no merging):

  • end_of_line → endOfLine
  • indent_style → useTabs
  • indent_size → tabWidth
  • max_line_length → printWidth
  • insert_final_newline → insertFinalNewline
Migrating from Prettier
# Install oxfmt
pnpm add -D oxfmt

# Auto-convert .prettierrc → .oxfmtrc.json
oxfmt --migrate=prettier

# Format everything so the diff is clean
pnpm oxfmt

# Replace Prettier scripts in package.json
# "prettier --write ."  → "oxfmt"
# "prettier --check ."  → "oxfmt --check"

After migration, review the generated .oxfmtrc.json — especially printWidth since the default changed from 80 to 100.

Editor integration

Editor extensions use the local oxfmt --lsp, so oxfmt must be installed in the project.

VS Code / Cursor: Install the "Oxc" extension from the VS Code Marketplace. Recommended team setup:

.vscode/extensions.json:

{ "recommendations": ["oxc.oxc-vscode"] }

.vscode/settings.json:

{
  "editor.defaultFormatter": "oxc.oxc-vscode",
  "editor.formatOnSave": true
}

Zed: Install the oxc extension from Zed's marketplace.

JetBrains (IntelliJ / WebStorm): Install from JetBrains Marketplace.

Neovim:

  • With nvim-lspconfig: npm i -g oxfmt then vim.lsp.enable('oxfmt')
  • With conform.nvim: set formatters_by_ft for js/ts/json/vue
  • With coc.nvim: :CocInstall coc-oxc

Other LSP-compatible editors (Emacs, Helix, Sublime): Point at oxfmt --lsp.

Non-LSP editors: Pipe via stdin: cat file.js | oxfmt --stdin-filepath file.js

CI setup

GitHub Actions:

jobs:
  format:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - uses: pnpm/action-setup@v4
      - uses: actions/setup-node@v6
        with:
          node-version: lts/*
          cache: pnpm
      - run: pnpm install --frozen-lockfile
      - run: pnpm run fmt:check

GitLab CI:

oxfmt:
  image: node:lts
  stage: test
  before_script:
    - npm install
  script:
    - npm run fmt:check

Autofix (GitHub): Use autofix.ci — run oxfmt (no --check) and let the action commit fixes.

Pre-commit hook (lint-staged)
{
  "lint-staged": {
    "*": "oxfmt --no-error-on-unmatched-pattern"
  }
}

Use --no-error-on-unmatched-pattern so non-supported file types don't cause errors.

Node.js API
import { format } from "oxfmt";

const result = format("foo.ts", "const   x:string   =   1", {
  semi: false,
  singleQuote: true,
});
console.log(result); // const x: string = 1

Workflow after code changes

When you've modified files in an oxfmt-enabled project:

  1. Run pnpm oxfmt (or the project's fmt script) to format changed files
  2. If in CI or a check context, use --check instead to verify without writing

The formatter is fast enough to run on the entire project — no need to target individual files unless piping via stdin.

Comments

Markdown supported