Skip to content

Migrate from Prettier

This guide covers migrating from Prettier to Oxfmt.

Quick start

For simple setups, migrate with a single command:

bash
$ npm add -D oxfmt@latest && npx oxfmt --migrate=prettier && npx oxfmt
``````bash [pnpm]
$ pnpm add -D oxfmt@latest && pnpm oxfmt --migrate=prettier && pnpm oxfmt
``````bash [yarn]
$ yarn add -D oxfmt@latest && yarn oxfmt --migrate=prettier && yarn oxfmt
``````bash [bun]
$ bun add -D oxfmt@latest && bunx oxfmt --migrate=prettier && bunx oxfmt
``````bash
npx skills add https://github.com/oxc-project/oxc --skill migrate-oxfmt
``````bash [npm]
$ npm add -D oxfmt@latest
``````bash [pnpm]
$ pnpm add -D oxfmt@latest
``````bash [yarn]
$ yarn add -D oxfmt@latest
``````bash [bun]
$ bun add -D oxfmt@latest
``````bash [deno]
$ deno add -D npm:oxfmt@latest
``````jsonc [.oxfmtrc.jsonc]
{
  "$schema": "./node_modules/oxfmt/configuration_schema.json",
  "printWidth": 80,
}
``````js [prettierrc.js]
module.exports = {
  singleQuote: true,
  jsxSingleQuote: true,
};
``````ts [oxfmt.config.ts]
import { defineConfig } from "oxfmt";

export default defineConfig({
  singleQuote: true,
  jsxSingleQuote: true,
  printWidth: 80,
});
``````yaml [prettierrc.yaml]
trailingComma: "es5"
tabWidth: 4
semi: false
singleQuote: true
``````jsonc [.oxfmtrc.jsonc]
{
  "$schema": "./node_modules/oxfmt/configuration_schema.json",
  "trailingComma": "es5",
  "tabWidth": 4,
  "semi": false,
  "singleQuote": true,
  "printWidth": 80,
}
``````diff
{
  "scripts": {
-   "format": "prettier --write .",
+   "format": "oxfmt",
-   "format:check": "prettier --check ."
+   "format:check": "oxfmt --check"
  }
}
``````diff
  - name: Check formatting
-   run: yarn prettier --check .
+   run: yarn oxfmt --check
``````diff
"lint-staged": {
- "*": "prettier --write --no-error-on-unmatched-pattern"
+ "*": "oxfmt --no-error-on-unmatched-pattern"
}
``````sh
npm run format