Code Indentation Tool
Re-indent code using a configurable number of spaces or tabs.
Paste your code and choose your target indentation (spaces or tabs, and how many) - this tool re-indents it consistently.
More Programming Language Tools
View all 23This adjusts indentation width/style only - it does not re-parse or validate the code's syntax for any specific language.
What Does This Tool Do?
It detects each line's current indentation level and re-applies it using your chosen indentation style (a specific number of spaces, or tabs) - a simple, language-agnostic way to normalize indentation.
Why Use This Tool?
Team members using different editor settings (tabs vs. spaces, 2 vs. 4 spaces) produce inconsistently-indented files - this tool normalizes a whole file to one consistent style in one pass.
How to Use It
- Paste your code.
- Choose spaces (and how many) or tabs.
- Copy the re-indented result.
Limitations
This works on relative indentation levels detected from your input - it doesn't validate or understand the syntax of any particular programming language.
Example
Code indented with tabs:
if (ready) {
start();
if (debug) {
log("started");
}
}
re-indented with 2 spaces becomes:
if (ready) {
start();
if (debug) {
log("started");
}
}
Common Conventions
| Language / tool | Usual indentation |
|---|---|
| Python (PEP 8) | 4 spaces |
| JavaScript / TypeScript (Prettier default) | 2 spaces |
| PHP (PSR-12) | 4 spaces |
| Go (gofmt) | Tabs |
| YAML | Spaces only (2 is common) |
| Makefiles | Tabs in recipes - required |
Prevent the Problem
Add an .editorconfig file to your repository so every editor uses the same settings:
root = true
[*]
indent_style = space
indent_size = 4
[Makefile]
indent_style = tab
For Python code, where indentation defines blocks, use the Python Formatter. For full formatting, try the Code Beautifier.
Frequently Asked Questions
Explore More Tools
Keep going with related categories and our most used tools.