You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Waiting on oxfmt to implement additional features? Consider using [@prettier/plugin-oxc](https://github.com/prettier/prettier/tree/main/packages/plugin-oxc) in Prettier to gain some parsing speed in the meantime.
13
+
Waiting on Oxfmt to implement additional features? Consider using [@prettier/plugin-oxc](https://github.com/prettier/prettier/tree/main/packages/plugin-oxc) in Prettier to gain some parsing speed in the meantime.
14
+
:::
15
+
16
+
## Features
17
+
18
+
- Support many kinds of file types
19
+
- JS/TS(X): Supported by `oxc_formatter`
20
+
- All file types supported by Prettier by default
21
+
- Faster alternative of Prettier CLI
22
+
- Over [30×](/blog/2025-12-01-oxfmt-alpha.html#performance) faster than Prettier’s experimental CLI without cache
23
+
- Experimental but usable features
24
+
- Native sort-imports
25
+
- Native sort-packagejson
26
+
27
+
## Supported languages
28
+
29
+
- JS, JSX
30
+
- TS, TSX
31
+
- JSON, JSONC, JSON5
32
+
- YAML
33
+
- HTML, Angular, Vue, MJML
34
+
- Ember, Handlebars
35
+
- CSS, SCSS, Less
36
+
- GraphQL
37
+
- Markdown, MDX
38
+
39
+
:::warning
40
+
41
+
Note that the `embeddedLanguageFormatting` option is not fully supported in JS/TS files. And for now, it is disabled by default.
42
+
14
43
:::
15
44
16
45
## Installation
@@ -65,78 +94,44 @@ $ bun add -D oxfmt
65
94
66
95
## Command-line Interface
67
96
68
-
`oxfmt` works like `prettier --write .` by default.
97
+
`oxfmt`CLI works like `prettier --write .` by default.
69
98
70
-
Formatting config options like `--no-semi` are not supported via CLI flags, we recommend setting these via the configuration file instead. This will ensure that the CLI and editor integrations always use the same settings.
99
+
Formatting config options like `--no-semi` are not supported via CLI flags.
100
+
We recommend setting these via the configuration file instead. This will ensure that the CLI and editor integrations always use the same settings.
71
101
72
102
Globs in positional paths are not expanded. (You can rely on your shell.) But `!`-prefixed exclude paths do support glob expansion.
73
103
74
104
See more details in the [CLI reference](./formatter/cli).
75
105
76
-
## Configuration file
77
-
78
-
By default, `oxfmt` automatically tries to find the nearest `.oxfmtrc.json` or `.oxfmtrc.jsonc` file from the current working directory. If not found, the default configuration options are used.
106
+
## Node.js API
79
107
80
-
You can also specify your config file with the `-c yourconfig.jsonc` flag.
108
+
`oxfmt` is also available via Node.js API: `format()` function.
81
109
82
-
Almost all formatting options are compatible with Prettier's [options](https://prettier.io/docs/options).
83
-
So you can migrate from Prettier by simply renaming `.prettierrc.json` to `.oxfmtrc.jsonc`.
110
+
```ts
111
+
import { format } from"oxfmt";
112
+
importtype { FormatOptions } from"oxfmt";
84
113
85
-
We also recommend adding the `$schema` to the config file after copying it:
See also [Configuration File](./formatter/config-file-reference).
98
-
99
-
## Ignore file
100
-
101
-
By default, `oxfmt` automatically finds the `.gitignore` and `.prettierignore` files from the current working directory.
123
+
## System Requirements
102
124
103
-
Also you can specify your ignore file by `--ignore-path your.ignore` flag.
104
-
105
-
VCS directories like `.git` and `.svn` are always ignored. Also global and nested ignores are not respected.
106
-
107
-
In addition, `.oxfmtrc.json(c)` supports an `ignorePatterns` field.
108
-
109
-
## Pre-commit hook
110
-
111
-
If you want to auto-format staged files with oxfmt in a git pre-commit hook, you can use `oxfmt --no-error-on-unmatched-pattern`.
112
-
113
-
This command is equivalent to `prettier --no-error-on-unmatched-pattern --write`, and will format all matched files that are supported by oxfmt. The `--no-error-on-unmatched-pattern` flag ensures that oxfmt will not raise errors if there are no supported files passed into the command by your pre-commit hook tool (e.g. only Ruby files are staged).
114
-
115
-
You can also pass `--check` to only _check_ the formatting of files, and bail if any files are incorrectly formatted.
116
-
117
-
If you are using a pre-commit hook via husky/lint-staged, you can run oxfmt with it by updating your package.json like so:
118
-
119
-
```json
120
-
"lint-staged": {
121
-
"*": "oxfmt --no-error-on-unmatched-pattern"
122
-
},
123
-
```
125
+
-**Node.js**: >= 20.19.0 or >= 22.12.0
126
+
-**Platforms**: darwin-arm64, darwin-x64, linux-arm64, linux-x64, win32-arm64, and win32-x64
124
127
125
128
## FAQs
126
129
127
-
### What kinds of files are supported?
128
-
129
-
Currently, only JavaScript and TypeScript files are supported (using all common JS/TS extensions and filenames, including `.js`, `.jsx`, `.ts`, `.mjs`, etc.).
130
-
JSX is always available in JS files, but for TypeScript, the `.tsx` extension is required to use JSX syntax.
131
-
132
-
Embedded parts like CSS-in-JS have experimental partial support.
133
-
By specifying `embeddedLanguageFormatting: auto`, non-substitution templates will be formatted.
134
-
135
130
### What is the compatibility with Prettier?
136
131
137
-
We're following the `main` branch of Prettier, not the `latest` release.
132
+
For JS/TS files, we're tested against the `v3.7.3`of Prettier.
138
133
139
-
For other differences, please see this discussion.
134
+
For known differences, please see this discussion.
140
135
141
136
> `Oxfmt` differences with `Prettier` · oxc-project/oxc · Discussion #14669\
@@ -148,24 +143,23 @@ The following are NOT currently supported:
148
143
-`prettier` field in `package.json`
149
144
- File formats other than `.json(c)`
150
145
- Nested configs in sub directories
151
-
-`override` field
152
-
-Respect`.editorconfig`
146
+
-`overrides` field
147
+
-Nested`.editorconfig` in sub directories
153
148
-`experimentalTernaries` and `experimentalOperatorPosition` option
154
149
155
-
Also, if `printWidth` is not specified, its default value is `100`. This differs from Prettier's default.
150
+
Also, if `printWidth` is not specified, its default value is `100`. This differs from Prettier's default`80`.
156
151
157
152
### Are Prettier plugins supported?
158
153
159
-
Currently, they are not supported.
160
-
161
-
For import sorting functionality, we provide experimental behavior based on `eslint-plugin-perfectionist/sort-imports` through the `experimentalSortImports` configuration option.
154
+
Currently, NOT supported.
162
155
163
-
### How does editor integration work?
156
+
However, for import sorting functionality, we provide experimental behavior based on `eslint-plugin-perfectionist/sort-imports` through the `experimentalSortImports` option.
164
157
165
-
For VS Code, the Oxc extension is available from the [Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=oxc.oxc-vscode) and [Open VSX Registry](https://open-vsx.org/extension/oxc/oxc-vscode).
158
+
And for `prettier-plugin-packagejson`, we have the `experimentalSortPackageJson` option, which is enabled by default.
166
159
167
-
For other editors, by running `oxfmt --lsp` you can start a language server that responds to standard `textDocument/formatting` requests.
160
+
See more details in the [Configuration file reference](./formatter/config-file-reference).
168
161
169
-
Formatting via stdin and stdout are not supported, but we have confirmed that some editors and extensions can work with the CLI by configuring them to use temporary files.
162
+
### Why are nested scripts and code blocks not formatted?
170
163
171
-
However, these methods have some limitations, such as not supporting formatting of embedded parts.
164
+
Currently, the `embeddedLanguageFormatting` option is `off` by default.
For full reference, see also [Configuration file reference](./config-file-reference).
18
+
19
+
By default, `oxfmt` automatically tries to find the nearest `.oxfmtrc.json` or `.oxfmtrc.jsonc` file from the current working directory. If not found, the default configuration options are used.
20
+
21
+
You can also specify your config file with the `-c yourconfig.jsonc` flag.
22
+
23
+
## `.editorconfig`
24
+
25
+
`.editorconfig` file is also supported by Oxfmt.
26
+
27
+
And these fields will override default options.
28
+
29
+
-`end_of_line`: `endOfLine`
30
+
-`indent_style`: `useTabs`
31
+
-`indent_size`: `tabWidth`
32
+
-`max_line_length`: `printWidth`
33
+
34
+
If both `.editorconfig` and `.oxfmtrc.json` has the same field, `.oxfmtrc` will win.
35
+
36
+
By default, `oxfmt` automatically tries to find the nearest `.editorconfig` file from the current working directory.
37
+
38
+
Unlike Prettier, Oxfmt does not respect `root = true` and does not merge nested `.editorconfig` files.
39
+
40
+
## Ignore files
41
+
42
+
By default, `oxfmt` automatically finds the `.gitignore` and `.prettierignore` files from the current working directory.
43
+
44
+
Also you can specify your ignore file by `--ignore-path your.ignore` flag.
45
+
In addition, `.oxfmtrc.json(c)` supports an `ignorePatterns` field.
46
+
47
+
Global and nested ignores are not respected.
48
+
49
+
VCS directories like `.git` and `.svn` are always ignored, also popular lock files are also ignored.
For VS Code, the Oxc extension is available from the [Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=oxc.oxc-vscode) and [Open VSX Registry](https://open-vsx.org/extension/oxc/oxc-vscode).
6
+
7
+
For other editors, by running `oxfmt --lsp` you can start a language server that responds to standard `textDocument/formatting` requests.
8
+
9
+
:::warning
10
+
11
+
Currently, LSP support has some limitations, such as not supporting formatting of embedded parts in JS/TS files, non-JS files support.
12
+
13
+
:::
14
+
15
+
Formatting via stdin and stdout are also supported.
In addition, we have confirmed that some editors and extensions can work with the CLI by configuring them to use temporary files.
22
+
23
+
## Pre-commit hook
24
+
25
+
If you want to auto-format staged files with Oxfmt in a git pre-commit hook, you can use `oxfmt --no-error-on-unmatched-pattern`.
26
+
27
+
This command is equivalent to `prettier --no-error-on-unmatched-pattern --write`, and will format all matched files that are supported by oxfmt. The `--no-error-on-unmatched-pattern` flag ensures that Oxfmt will not raise errors if there are no supported files passed into the command by your pre-commit hook tool (e.g. only Ruby files are staged).
28
+
29
+
You can also pass `--check` to only _check_ the formatting of files, and bail if any files are incorrectly formatted.
30
+
31
+
If you are using a pre-commit hook via husky/lint-staged, you can run Oxfmt with it by updating your package.json like so:
Before migrating, ensure that the current release of the Oxfmt alpha meets your project's needs. It is almost entirely compatible with Prettier v3.7 already for basic configurations, but less-common config options and other features are not yet implemented.
14
-
15
-
<!-- TODO: Remove this note when oxfmt 0.17.0 ships with many of the missing languages. -->
9
+
Before migrating, ensure that the current release of the Oxfmt alpha meets your project's needs.
16
10
17
-
The Oxfmt alpha only supports formatting JavaScript and TypeScript files (including those with JSX syntax). If you need support for non-JSX frameworks like Vue or Ember, or other languages like JSON, YAML, or Markdown, you will likely want to wait.
11
+
It is almost entirely compatible with Prettier v3.7 already for basic configurations, but less-common config options and other features are not yet implemented.
18
12
19
13
Other important considerations when migrating from Prettier to Oxfmt:
20
14
@@ -79,6 +73,14 @@ If you have a basic `.prettierrc` file, you can simply rename the file with `mv
79
73
80
74
If you are using something other than JSON to configure Prettier, you will need to convert the configuration to JSON.
81
75
76
+
In either case, you can use the migrate command in your project root directory.
77
+
78
+
```sh
79
+
oxfmt --migrate prettier
80
+
```
81
+
82
+
This command automatically finds your configuration file and converts it to `.oxfmtrc.json` if possible.
83
+
82
84
### `prettierrc.js`
83
85
84
86
Here's an example of migrating a `prettierrc.js` file.
0 commit comments