Build an .editorconfig file that keeps indentation, line endings and whitespace consistent across every editor your team uses. Start from a language preset, adjust each file pattern, and test which rules apply to any path before you commit it.
Last updated:
Sections
Quick add:
.editorconfig
Save it as .editorconfig (with the leading dot) in your project root. If your browser drops the dot when downloading, rename the file.
Advertisement
Advertisement
How to use the EditorConfig Generator
Pick a preset for your main language and click Load preset, or import an existing .editorconfig.
Edit the sections: change the file pattern in brackets and choose values for each property. Leave a property as (not set) to keep the editor's default.
Add sections for special files with the quick-add buttons, for example Makefiles that need tabs or Markdown that keeps trailing spaces.
Test a path such as src/app.ts to see the matching sections and the settings an editor will use.
Copy or download the file and save it as .editorconfig in the root of your project.
EditorConfig properties reference
Property
Values
What it controls
root
true
Top of the file only (outside any section): stop looking for .editorconfig files in parent folders.
indent_style
space, tab
Whether the Tab key and auto-indent insert spaces or tab characters.
indent_size
whole number, tab
Columns per indentation level.
tab_width
whole number
Display width of a tab character; defaults to indent_size.
end_of_line
lf, crlf, cr
Line break written when saving: LF for Unix/macOS, CRLF for Windows.
charset
utf-8, utf-8-bom, latin1, utf-16be, utf-16le
File encoding. Use utf-8 unless a tool needs a BOM.
trim_trailing_whitespace
true, false
Remove spaces at the ends of lines on save.
insert_final_newline
true, false
Make sure the file ends with a line break.
max_line_length
whole number, off
Guide or wrap column; supported by some editors only.
Any property can also be set to unset, which removes a value inherited from an earlier section so the editor falls back to its own default. Property names and values are case-insensitive.
Glob patterns cheat sheet
Pattern
Matches
*
Any string except /; [*] on its own matches every file
**
Any string including /, so src/**.ts matches TypeScript files at any depth under src
?
Exactly one character (not /)
[abc], [!abc]
One character from the set, or not in the set
{js,ts,tsx}
Any of the comma-separated alternatives, e.g. *.{js,ts,tsx}
{1..5}
Any whole number from 1 to 5, e.g. chapter{1..5}.md
Pair EditorConfig with a formatter for full consistency: the Prettier Config Generator builds a matching .prettierrc, and Prettier reads indent_style, indent_size/tab_width, max_line_length and end_of_line from .editorconfig when they are not set in its own config.
Frequently asked questions
What is an .editorconfig file?
It is a small INI-style text file that tells code editors how to format files in a project: spaces or tabs, indent width, line endings, character set and whitespace trimming. Many editors read it natively (JetBrains IDEs, Visual Studio, Vim, Neovim, GitHub's web editor) and others such as VS Code need the EditorConfig extension.
Where do I put the .editorconfig file?
Save it in the root folder of your repository and commit it. Editors look for .editorconfig in the file's folder and every parent folder; root = true in the top file stops that search so settings from outside the project are ignored.
How do sections and patterns work?
Each [section] header is a file pattern. Later sections override earlier ones for the properties they set, so put [*] defaults first and specific patterns after it. A pattern without a slash, such as *.md, matches files in any folder; a pattern with a slash, such as lib/**.js, is relative to the folder containing .editorconfig.
What is the difference between indent_size and tab_width?
indent_size is how many columns one indentation level uses. tab_width is how wide a tab character is displayed. If you indent with spaces you normally only set indent_size; tab_width defaults to the same value. Setting indent_size = tab means one indent equals one tab of tab_width columns.
Does EditorConfig reformat my existing files?
No. It only changes how editors behave when you type and save: new indentation, the line endings written, trimming trailing spaces on save and so on. Existing files keep their formatting until edited or run through a formatter like Prettier.
Is max_line_length supported everywhere?
No. max_line_length is a domain-specific property that some editors honour (JetBrains IDEs, Vim with the plugin, Emacs) while others ignore it. Formatters such as Prettier read it as printWidth when no other setting is given.
Is anything uploaded?
No. The file is generated in your browser. Your last configuration is saved only in this browser's local storage so it is there when you come back.
Are all the tools on FreeToolCabin tested for quality and accuracy?
Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.