Course contentsShow
← JavaScript
Lesson 2581 of 2,72352. Linting and FormattingFree lesson

Format-on-Save in Your Editor

Enable automatic formatting on save in VS Code, WebStorm, and other editors via Prettier extensions.

Format-on-Save in Your Editor

You'll learn: How to configure your code editor to automatically run Prettier every time you save a file, eliminating manual formatting steps.

What Is Format-on-Save?

Format-on-save means your editor automatically applies Prettier's formatting rules the instant you hit Ctrl+S (or Cmd+S on Mac). Instead of running prettier --write from the command line or remembering to format before committing, your code becomes perfectly styled automatically with every save.

Think of it like autocorrect on your phone—except instead of fixing typos, it fixes spacing, indentation, and code style instantly and invisibly.

Setting It Up

VS Code:

  1. Install the Prettier - Code formatter extension (by Prettier)
  2. Open Settings (JSON or UI)
  3. Enable format-on-save:
    "editor.formatOnSave": true,
    "editor.defaultFormatter": "esbenp.prettier-vscode"
    

WebStorm/IntelliJ:

  1. Go to Settings → Languages & Frameworks → JavaScript → Prettier
  2. Set the Prettier package path (usually auto-detected from node_modules)
  3. Check "On save" under Run for files

Other Editors: Most modern editors (Sublime Text, Atom, Vim, Emacs) have Prettier plugins with format-on-save options. Search for "Prettier [your editor name]" and follow the plugin's documentation.

Why This Matters

Format-on-save creates a frictionless workflow. You never think about formatting—it just happens. Your entire team gets consistent code style without anyone needing to remember commands or shortcuts. It's the final piece that makes Prettier feel invisible and effortless.

Key Takeaway: Enabling format-on-save in your editor automates Prettier formatting with every file save, ensuring consistent code style without manual intervention.