VSCode Format on save for only one language

October 20, 2026

Based on this article, you may find interest in these:

Are you ever stuck with VSCode formatting files that you didn’t want it to touch? Thank god there’s a simple fix for that.

I like format on save for Python and TypeScript, but not for Markdown, where it messes up my blog posts. VSCode lets you set editor.formatOnSave for a single language.

Prerequisites

  • VSCode installed
  • A formatter for the language, for example Prettier or Black

Steps to set format on save for one language

  1. Open the Command Palette using CTRL + Shift + P on Windows or ⌘ + Shift + P on Mac
  2. Search for Preferences: Open User Settings (JSON)
  3. Add a block for the language you want, like this:
"editor.formatOnSave": false,
"[python]": {
  "editor.formatOnSave": true
},
"[typescript]": {
  "editor.formatOnSave": true
}

The first line turns it off everywhere, and the blocks turn it on for each language you list. You can also do it the other way around: turn it on everywhere and set it to false for [markdown].

To find the name of a language, open a file of that type and look at the language name in the bottom right corner. Click it to see the id.


Profile picture

Written by An anonymous coder who lives and works building useful things. Mostly focusing on Django, Vue and overall Python examples.