Guide · Open source
How to use standard: JavaScript style checker and auto-fixer
Updated · written with AI from the project's own documentation and checked against our catalogue data
Standard is a JavaScript style guide enforced by a linter, which is a tool that checks code for formatting problems and common programmer mistakes. This guide shows you how to install it with npm, check your files, fix many issues automatically and wire it into your project's test script. By the end you will be able to run standard on a project without writing a configuration file.
Quick start
- 1Check prerequisites. Make sure Node.js and npm are installed on your computer.
- 2Install standard. Run npm install standard --global for a system-wide command, or npm install standard --save-dev inside a project.
- 3Run a first check. Run standard, or npx standard for a local install, to see style problems in your JavaScript files.
- 4Fix what you can. Run standard --fix to automatically correct many style issues.
- 5Add it to package.json. Add standard to devDependencies and put standard in your test script.
- 6Run npm test. Run npm test so style is checked each time you test the project.
What you need before you install standard
Standard is installed with npm, so you need Node.js and npm on your machine. The project's README notes that both must be installed before you run the install commands.
- Node.js
- npm
Install standard globally or in a single project
You can install standard as a global command line program, which makes the standard command available everywhere. Or you can install it locally for one project as a development dependency.
- Global install: run the global command once on your machine.
- Local install: use this for a single project so the version is tied to that project.
$ npm install standard --global
$ npm install standard --save-devCheck your JavaScript files with standard
Run standard with no arguments to check all JavaScript files in the current directory. If you installed it locally, the README says to run it with npx instead. Output lists each problem with its file, line and column.
To check specific folders, pass glob patterns in quotes so standard expands them rather than your shell. By default standard looks for **/*.js and **/*.jsx files.
$ standard
$ npx standard
$ standard "src/util/**/*.js" "test/**/*.js"Fix style issues automatically with --fix
Run standard --fix to automatically correct many style issues. The README says this is how you can clear messy or inconsistent formatting without editing each line by hand. Some problems, such as the programmer errors the linter reports, may still need your attention after the fix runs.
$ standard --fixRun standard automatically with npm test
You can add standard to the scripts section of package.json so that style is checked whenever you run npm test. Add it as a dev dependency, then chain it with your other test commands using &&. The README's example runs standard before a test file.
- Add standard under devDependencies.
- Put standard && node my-tests.js in the test script.
- Run npm test to check style and tests together.
{
"name": "my-cool-package",
"devDependencies": {
"standard": "*"
},
"scripts": {
"test": "standard && node my-tests.js"
}
}Decide whether standard fits your project
Standard is built around having no configuration. The README says the style is fixed by design, so you cannot tune many individual rules. Teams that want to adjust a lot of rules, want Prettier-style output, or need to lint non-JavaScript files should compare it with other tools such as ESLint, Prettier or XO before adopting it.
- Good fit: teams that want to stop debating style and keep contributor expectations clear.
- Poor fit: teams that need many custom rules or non-JavaScript linting.
What people use it for
- Enforcing one consistent JavaScript style across a team without writing rules.
- Adding a quick style check to the npm test script of a Node.js package.
- Giving open source contributors clear, automated style expectations before pull request review.
- Cleaning up inconsistent formatting in existing JavaScript files with standard --fix.
Frequently asked questions
How do I install standard?
Run npm install standard --global to use it as a command line program everywhere, or npm install standard --save-dev to install it in one project. The README notes that Node.js and npm must be installed first.
Does standard need a configuration file?
No. The project is designed so you do not need to write or maintain a configuration file, and the README says there are no .eslintrc files to manage.
How do I automatically fix style errors?
Run standard --fix. The README says this automatically corrects many style issues, though some reported problems may still need manual fixes.
Which files does standard check?
By default it checks files matching **/*.js and **/*.jsx. You can pass other glob patterns in quotes to check specific folders.
Can I use standard with ESLint or Prettier?
The README lists ESLint, Prettier and XO as comparable projects and links a talk on when to use standard versus eslint. It does not describe standard as a replacement for Prettier, so check the trade-offs before choosing.
Can I change or disable individual rules in standard?
The README says standard has no configuration and the style is fixed by design, so it is not built for changing many rules. The source does not describe per-rule toggles, so do not assume they exist.
New agent skills, repos and AI tools — every week
The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.
Our verdict
Standard suits JavaScript and Node.js projects that want a fixed, zero-config style check and clear rules for contributors. Teams that want to customize many rules, prefer Prettier-style formatting, or lint non-JavaScript files should pick a different tool such as ESLint, Prettier or XO.
Install options & downloads