Blog
Text tools

Remove spaces before punctuation

Paste your text and the tool removes any space (or several in a row) that ends up right before , . ! ? : ; ) ] }. Handy after pasting text from a chat app, where a stray space before punctuation is common, or after running text through machine translation.

Result

Spaces fixed —

All calculations run locally in your browser: parsing, chart, export. Disconnect the network and the page keeps working.

Facts and limits of this method

Marks handled , . ! ? : ; ) ] }
What gets removed One or more spaces in a row right before the mark
Regular expression /[ \t]+([,.!?:;)\]}])/g → "$1"
Space after the mark Untouched — only the space before the mark is removed
Line breaks Not treated as a space by this tool and never removed
Opening brackets ( [ { are not in the list — a space before them is usually correct

When it misleads you

How it is calculated

The text is scanned with a regular expression that looks for one or more whitespace characters (a regular space or a tab) immediately followed by one of , . ! ? : ; ) ] }.

Each match is replaced with just the punctuation mark, with no space before it — so "word ." becomes "word.", and "word ," (several spaces) becomes "word,".

The "spaces fixed" counter tracks how many such replacements were made — in other words, how many times a mark was preceded by an extra space before processing.

The whole text is processed at once, not line by line — line breaks and paragraphs are preserved exactly as in the source text.

Questions and answers

Will it remove the space before an opening bracket?

No, on purpose. Opening brackets ( [ { are not in the list of handled marks, because a space before them is usually correct by punctuation rules.

What happens to several spaces in a row before a mark?

All of them are removed at once — "word !" becomes "word!", not "word !" with one space left behind.

Are line breaks treated as spaces?

No. The tool only looks for spaces and tabs. If a punctuation mark starts a new line after the text, the line break is not removed.

Does it add a space after punctuation when one is missing?

No, this tool only removes extra spaces before marks. Adding missing spaces after punctuation is a job for a separate tool.

Is my text sent anywhere?

No. All processing happens in your browser; the text is never transmitted anywhere.

Related tools

All tools