EditorConfig Generator
Set shared rules for indentation, encoding and line endings across the repository.
-
1Enter data
Enter content, paste text or load a file from disk. -
2Click the button
The tool will immediately process your data in the browser. -
3Get the result
Copy the finished text or save the file to your device.
return "Result ready in 0.1s";
}
Rate this tool:
Related tools
Other tools you may find usefulEditorConfig generator - one set of indentation rules for the whole team
The EditorConfig generator assembles a ready configuration file from seven decisions: spaces or tabs, indent width, encoding, line ending, a final newline, trailing whitespace trimming and a Markdown exception. Copy the result into the root of your repository and every editor on the team formats code the same way, regardless of personal preferences.
What .editorconfig is and why it works
.editorconfig is a plain text file in INI format that describes formatting rules per file name pattern. It is not a command you run in a terminal and not a project dependency - it is configuration read by the editor itself. Because the file is versioned alongside the code, a new team member gets the right indentation right after the first git clone. The root = true entry at the top matters: without it the editor keeps searching parent directories and may pull in rules from a different project. The generator always writes that line.
Which rules the generator sets
| Property | Values | What it changes |
|---|---|---|
indent_style | space, tab | Spaces or a tab character |
indent_size | 1-12 | Spaces in one indentation level |
tab_width | 1-12 | Width of a tab on screen |
charset | utf-8, utf-8-bom, latin1 | Encoding the file is saved in |
end_of_line | lf, crlf, cr | Character that terminates a line |
insert_final_newline | true, false | Empty line at the end of the file |
trim_trailing_whitespace | true, false | Trimming spaces at line ends |
How to build the file step by step
- Pick the Spaces or Tabs tile. In tab mode the generator writes
tab_width, because the width of a tab is a display concern rather than a count of characters. - Enter an indent width between 1 and 12. A value outside that range stops generation and shows a message instead of quietly substituting something else.
- Set the encoding and the line ending. The defaults,
utf-8withlf, are the safe choice for projects that build on Linux. - Decide on the final newline and on trailing whitespace trimming. Both switches write an explicit
trueorfalse. - Click Generate .editorconfig, copy the output and save it as
.editorconfigin the root of the repository.
At the start of a repository it is worth adding an ignore list from the gitignore generator next to it, and for Apache projects a configuration from the .htaccess file generator.
Narrower indents for frontend files
When you choose spaces and a width larger than two, the generator appends a section for js, jsx, ts, tsx, css, scss, json, yml, yaml and html files with a two space indent. That convention rules the JavaScript ecosystem and nested data files. At a width of one or two spaces the section is skipped, because it would repeat the global rule.
.php, .py, .go and .rs files are deliberately kept out of that list: PSR-12, PEP 8 and rustfmt call for four spaces, gofmt for tabs. They inherit the rule from the [*] section. One exception is always enforced: if you pick tabs globally, a separate spaces-only section is written for .yml and .yaml, because the YAML specification forbids tabs as indentation. A file indented with tabs will not parse at all, as a YAML validator confirms.
Line endings, Git and phantom changes in diffs
Windows terminates a line with a CR and LF pair, Unix-like systems with a single LF. Without a shared rule Git reports an entire file as modified even though nobody touched the code. Setting end_of_line = lf solves it on the editor side, paired with a .gitattributes file containing * text=auto eol=lf, which normalizes content inside the repository. If a diff still looks suspicious, inspect it with a code difference checker, and clean up indentation in HTML or CSS with the JS, CSS and HTML code beautifier.
Why Markdown needs an exception
In Markdown two spaces at the end of a line mean a forced line break. An editor with trim_trailing_whitespace enabled strips them on every save and quietly breaks your documentation. That is why the generator adds a section disabling the rule for .md and .markdown files:
[*.{md,markdown}]
trim_trailing_whitespace = false
The section appears only when you trim whitespace globally - otherwise it would be an entry with no effect.
Frequently asked questions
How is .editorconfig different from Prettier or PHP CS Fixer?
EditorConfig acts while you type and save, setting a few basic editor properties. Formatters such as Prettier, PHP CS Fixer or Black rebuild the whole file by their own rules and you run them from a terminal or a hook. The two do not compete: Prettier reads .editorconfig itself and takes indentation and line endings from it unless you override them in its own configuration.
Does the file work in every editor?
VS Code, every JetBrains IDE and Visual Studio read it without add-ons. Vim, Emacs, Sublime Text and Notepad++ need a plugin. An editor that does not understand it simply ignores the file.
Can I keep several .editorconfig files in one project?
Yes. The editor walks up from the directory of the edited file and merges rules until it hits root = true. Rules from directories closer to the file win. In a monorepo a frontend package can use two spaces while a Python service uses four.
What does utf-8-bom do and when should I pick it?
utf-8-bom writes a byte order mark at the start of the file. Only older Windows tooling needs it, for example some PowerShell 5 scripts. In PHP files the mark is harmful, because it lands in the HTTP response ahead of the headers - without a concrete reason, stay with utf-8.
Will .editorconfig fix files that are already in the repository?
Not immediately. The rules apply to a file when it is edited and saved, so existing code changes gradually. Do a one-off reformat with a dedicated formatter in a separate commit, recorded in .git-blame-ignore-revs so history stays readable.