Convert Tabs to Spaces in Atom

Learn how to convert tabs to spaces in Atom, configure tab length and soft tabs, and verify indentation changes in your files.

Before you start

This procedure changes indentation inside an open file in the Atom editor. It works locally on your computer and does not require an online service or an account. You should have the file open and be sure that you want to modify its indentation; the change affects the open buffer, and you can keep a copy of the file if you want an easy fallback.

Step-by-step instructions

First select the part of the file you want to change. If you want to convert indentation in the whole document, put the cursor anywhere in the file or select all text.

Open the command palette with Ctrl+Shift+P on Windows or Linux, or Cmd+Shift+P on macOS.

Type Whitespace: Convert Tabs to Spaces and run that command. Atom replaces each leading tab in the selection or file with space characters according to the current tab length setting.

If you need spaces to be used for new indentation as well, open Settings, select Editor, and enable Soft Tabs. The Tab Length value controls how many spaces are used for each tab or indent level.

The exact menu labels and available packages can differ between Atom versions, so use the command palette name if a menu item is not visible in your version.

Check the output

Enable invisible characters from the editor settings or use the Toggle Invisible Characters command. Tabs are then shown with a different marker from spaces, which helps you confirm that the leading tabs were replaced.

Check the beginning of the changed lines. The command changes leading indentation, but it does not remove tabs that appear in the middle of a line as part of the content.

If your project uses a specific indentation style, compare the visible indentation with the expected number of spaces from your project settings or style guide.

Common problems and next steps

If a keyboard shortcut for indentation controls is not available, use the command palette instead; Atom exposes these actions as commands that can be run even when a toolbar button is missing.

When indentation appears inconsistent after conversion, check the Tab Length setting. Files created with a different tab length may look misaligned until the setting matches the spacing used by the project.

The editor may keep using tabs for new lines if Soft Tabs is disabled. Enable Soft Tabs to make new indentation use spaces, then run the conversion command again for any remaining tab-indented lines.

Undo is available with Ctrl+Z or Cmd+Z immediately after the change if the result is not what you expected.