I am using the VS Code prettier plugin to format my code, how can I add a setting to not add or remove semicolons when I format my code? I know that this feature was added in January but I found no mention in the PR or issue of how to add it to settings.
Asked
Active
Viewed 9.2k times
3 Answers
132
From the readme:
prettier.semi (default: true)
Whether to add a semicolon at the end of every line (semi: true), or only at the beginning of lines that may introduce ASI failures (semi: false)
You have to set prettier.semi
to false
.
To change prettier settings see,
Like all other vscode settings
note: These settings are prefixed with prettier.
-
44{ "semi": false} in the .prettierrc file – Aindriú Jul 28 '20 at 13:11
-
1Why can I not find the prettier settings anywhere? – Junglemath Apr 05 '21 at 20:28
-
Can I setting `semi: false` for all module except of class in `type script` ? – soroush Feb 18 '22 at 11:38
-
this did not work in my case. Always added the semicolons back although i did exactly whats in the post. – Felkru Jul 04 '23 at 16:59
17
Open settings.json
file*.
Add this lines to format your code on save and to remove semicolons on save:
"editor.formatOnSave": true,
"prettier.semi": false,
Use Ctrl+P to search for file in Vs Code.*

Qui-Gon Jinn
- 3,722
- 3
- 25
- 32
-
1Doesn't work, but the built-in formatter works with `"javascript.format.semicolons": "remove"` – Filip Seman Aug 16 '22 at 10:56
11
In your Prettier
settings. Add the following
semi: false
- If you want to format your file using CLI, then
prettier --write --no-semi your_file

Junip Dewan
- 759
- 8
- 8