If you want a certain file in a repo to never be formatted by prettier, you can add it to a .prettierignore file: Disable Prettier for one file

From the docs:

To exclude files from formatting, create a .prettierignore file in the root of your project. .prettierignore uses gitignore syntax.

Example:

# Ignore artifacts: 
build 
coverage

# Ignore all HTML files:
*.html 
Answer from Zunaib Imtiaz on Stack Overflow
🌐
Prettier
prettier.io › docs › ignore
Ignoring Code · Prettier
Use .prettierignore to ignore (i.e. not reformat) certain files and folders completely.
Top answer
1 of 8
111

If you want a certain file in a repo to never be formatted by prettier, you can add it to a .prettierignore file: Disable Prettier for one file

From the docs:

To exclude files from formatting, create a .prettierignore file in the root of your project. .prettierignore uses gitignore syntax.

Example:

# Ignore artifacts: 
build 
coverage

# Ignore all HTML files:
*.html 
2 of 8
69

Thanks to evolutionxbox, so far couple of solutions were found.

Ignoring Files or Folders

To exclude files from formatting, add entries to a .prettierignore file in the project root or set the --ignore-path CLI option. .prettierignore uses gitignore syntax.

/app/src/scripts/example.js
/app/src/folder/

Ignore based on extension

To exclude files based on extesntion you can add entries to a .prettierignore file as well

*.html.erb

Ignore lines

JavaScript

A JavaScript comment of // prettier-ignore will exclude the next node in the abstract syntax tree from formatting.

    matrix(
      1, 0, 0,
      0, 1, 0,
      0, 0, 1
    )

    // prettier-ignore
    matrix(
      1, 0, 0,
      0, 1, 0,
      0, 0, 1
    )

will be transformed to:

    matrix(1, 0, 0, 0, 1, 0, 0, 0, 1);

    // prettier-ignore
    matrix(
      1, 0, 0,
      0, 1, 0,
      0, 0, 1
    )

JSX

    <div>
      {/* prettier-ignore */}
      <span     ugly  format=''   />
    </div>

more: https://prettier.io/docs/en/ignore.html

Using an extension

We can use an extension to toggle formatting like prettier on the specific page when you need it.

Formatting Toggle https://marketplace.visualstudio.com/items?itemName=tombonnike.vscode-status-bar-format-toggle

🌐
GitHub
github.com › prettier › prettier › issues › 4547
Ignore commonly generated folders · Issue #4547 · prettier/prettier
May 25, 2018 - At the moment, Prettier ignores node_modules/. In my experience, folders coverage and dist are commonly used to contain generated artifacts and could be ignored accordingly, as a sensible default. If someone really needs to include those...
Published   May 25, 2018
Author   astorije
🌐
Devinschumacher
devinschumacher.com › how-to-disable-prettier-formatting-for-individual-files-or-folders
how to disable prettier formatting for individual files or folders | Devin Schumacher
August 27, 2022 - this one is my favorite, because i typically open files directly without having their parent directory open in vs code - which i am noticing makes the .prettierignore file in the folder not work... ... {/* prettier-ignore-start */} now you can write multi-line things and it wont format them!
🌐
Prettier
prettier.io › docs › cli
CLI · Prettier
It’s recommended to always make sure that prettier --write . only formats what you want in your project. Use a .prettierignore file to ignore things that should not be formatted.
🌐
npm
npmjs.com › package › prettier-ignore
prettier-ignore - npm
June 4, 2025 - npx prettier --ignore-path ./node_modules/prettier-ignore/prettierignore .
      » npm install prettier-ignore
    
Published   Jun 04, 2025
Version   0.4.0
Author   hellozmj@qq.com
🌐
GitHub
github.com › prettier › prettier › issues › 11568
prettier recurses into directories ignored by .prettierignore · Issue #11568 · prettier/prettier
July 24, 2021 - mkdir -p prettier-test/ignore-me/root-only-dir cd prettier-test/ echo ignore-me > .prettierignore echo '{}' > foo.json echo '{}' > ignore-me/root-only-dir/foo.json sudo chown root:root ignore-me/root-only-dir/ sudo chmod 700 ignore-me/root-only-dir/
Author   aspiers
🌐
Lightrun
lightrun.com › answers › prettier-prettier-ignore-commonly-generated-folders
Ignore commonly generated folders
August 30, 2024 - If someone really needs to include those, adding !coverage/ and/or !dist/ in .prettierignore should re-include them. ... I think all entries in .gitignore should be ignored by Prettier without the need to specify --ignore-path .gitignore. The .gitignore should be a constant with the option to additionally use a .prettierignore.
Find elsewhere
🌐
JetBrains
youtrack.jetbrains.com › issue › WEB-49880
Prettierignore is ignored for subfolders with package.json
{{ (>_<) }} This version of your browser is not supported. Try upgrading to the latest stable version. Something went seriously wrong
🌐
Jacob Paris
jacobparis.com › content › prettier-opt-in
Configure Prettier for Opt-In Usage
February 16, 2024 - By adding a .prettierignore file, you can stop Prettier from formatting certain files and directories. ... It's important to target only files *.* and not directories, as you cannot "un-ignore" the child of an ignored directory.
🌐
GitHub
github.com › prettier › prettier-vscode › issues › 578
.prettierignore ignore everything except specific folder · Issue #578 · prettier/prettier-vscode
September 5, 2018 - .prettierignore file: # Ignore everything: * # Except myapp folder: !myapp/ When running prettier from console - works great, changes in myapp folder are formatted by prettier and changes in other ...
Author   tlareg
🌐
GitHub
github.com › prettier › prettier › issues › 1977
How to ignore one or more folders/files in CLI? · Issue #1977 · prettier/prettier
July 5, 2023 - I tried this on CLI and it works. prettier --write --use-tabs /Users/jitendravyas/app-v3/styles/**/*.scss But I want to ignore some folders like /Users/jitendravyas/app-v3/styles/vendor/**/*.scss /Users/jitendravyas/app-v3/styles/sprite-...
Author   jitendravyas
🌐
GitHub
github.com › prettier › prettier › blob › main › .prettierignore
prettier/.prettierignore at main · prettier/prettier
# Ignore directories and files in 'tests/format' /tests/format/**/*.* # Unignore directories and 'format.test.js' file · !/tests/format/**/ !/tests/format/**/format.test.js · /tests/integration/cli/ !/tests/integration/plugins/automatic/node_modules/@prettier/plugin-foo/index.js ·
Author   prettier
🌐
JetBrains
youtrack.jetbrains.com › issue › WEB-32711
Prettier: support .prettierignore : WEB-32711
{{ (>_<) }} This version of your browser is not supported. Try upgrading to the latest stable version. Something went seriously wrong
🌐
GitHub
github.com › prettier › prettier › issues › 8048
Multiple files for --ignore-path · Issue #8048 · prettier/prettier
April 14, 2020 - I use the --ignore-path argument and point it to an exhaustive .gitignore file. It's great that I don't have to duplicate the list of ignored files. However, there are a couple of files I'd like to exclude from prettifying but still want...
Author   alfechner
🌐
GitHub
github.com › prettier › prettier-vscode › issues › 311
.prettierignore pattern to ignore an entire folder · Issue #311 · prettier/prettier-vscode
February 27, 2024 - I have some folders I want to disable prettier completely, and let it run on other folders with formatOnSave. tried to add .prettierignore with **/* and **/ with no effect - prettier still formats ...
Author   tomeraz
🌐
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 12445706878226-How-to-exclude-files-from-Prettier-glob-pattern
How to exclude files from Prettier glob pattern? – IDEs Support (IntelliJ Platform) | JetBrains
July 11, 2023 - You can create a .prettierignore file that looks something like this: *.min.* in your project root folder · Sebastian Obentheuer · Created July 20, 2023 09:12 · That works. Thank you so much, Elena.
🌐
Lightrun
lightrun.com › answers › prettier-prettier-vscode-prettierignore-ignore-everything-except-specific-folder
.prettierignore ignore everything except specific folder
To exclude files from formatting, create a .prettierignore file in the root of ... .prettierignore ignore everything except specific folder #578 - GitHub....Read more >
🌐
Naftalimurgor
naftalimurgor.com › how-to-ignore-certain-files-prettier
How To Ignore Certain Files When Using Prettier :: naftalimurgor.com - Example site for hugo-theme-tailwind
February 27, 2024 - Introduction Plenty of times in a project we’d wish to ignore the linting of certain files when using Prettier. Ignoring files: .prettierignore To ignore certain files, add the file name to .prettieringore file in your project root and prettier will ignore the file.