How to remove a trailing comma from text in Excel
Formula (Excel and Google Sheets)
=IF(RIGHT(A2)=",",LEFT(A2,LEN(A2)-1),A2)Drop the last character only when it is a comma: =IF(RIGHT(A2)=",",LEFT(A2,LEN(A2)-1),A2).
- Result on the example
- one result per row in
B2, filled down toB6 - Works in
- Microsoft 365 only
- Google Sheets
- Same formula
See it work
The formula is already in B2, filled down to B6. Change any input and the result updates, or edit the formula to experiment.
How it works
RIGHT with no length returns the last character. If it is a comma, LEFT keeps everything except it; if not, the text comes back unchanged. That is the difference from simply cutting the last character off every row.
=IF(RIGHT(A2)=",",LEFT(A2,LEN(A2)-1),A2)Result"chair, desk, lamp"
A2"chair, desk, lamp,"The value in A2.
RIGHT(A2)","RIGHT: Characters from the end of text.- text
A2"chair, desk, lamp,"
- text
RIGHT(A2)=","TRUEThe = operator tests whether the two sides are equal.
LEN(A2)18LEN: Number of characters.- text
A2"chair, desk, lamp,"
- text
LEN(A2)-117The - operator subtracts.
LEFT(A2,LEN(A2)-1)"chair, desk, lamp"LEFT: Characters from the start of text.- text
A2"chair, desk, lamp," - num_chars
LEN(A2)-117
- text
IF(RIGHT(A2)=",",LEFT(A2,LEN(A2)-1),A2)"chair, desk, lamp"IF: Returns one value if a test is true, another if false.- logical_test
RIGHT(A2)=","TRUE - value_if_true
LEFT(A2,LEN(A2)-1)"chair, desk, lamp" - value_if_false
A2"chair, desk, lamp,"not used
- logical_test
In Google Sheets
The same formula works in Google Sheets: =IF(RIGHT(A2)=",",LEFT(A2,LEN(A2)-1),A2). We ran it in Google Sheets mode on the same data and it returns the same results.
Other ways to do it
Each one was run on the same example sheet.
| Formula | Result | When to use it |
|---|---|---|
| =IF(RIGHT(TRIM(A2))=",",LEFT(TRIM(A2),LEN(TRIM(A2))-1),TRIM(A2)) | chair, desk, lamp, monitor, dock, cable… | Trims first, so a comma followed by a space ("dock, cable, ") is caught too. |
| =REGEXREPLACE(A2,",\s*$","")Google Sheets | chair, desk, lamp, monitor, dock, cable… | Google Sheets: delete a comma and any spaces at the very end. |
Common mistakes
- A space after the comma hides it from RIGHT. Use the TRIM version for exported data.
- Two trailing commas lose only one. In Google Sheets,
",+\s*$"removes them all.
Try it yourself
Same data, empty answer cell. Your formula is graded instantly, then re-checked on changed data, so a typed-in number won't pass.
Remove a trailing comma from text
B2, remove the comma at the end of the list if there is one, and fill down to B6.Questions
How do I remove a trailing slash from URLs?
Swap the character: =IF(RIGHT(A2)="/",LEFT(A2,LEN(A2)-1),A2).
How do I remove a leading comma?
Check the first character: =IF(LEFT(A2)=",",MID(A2,2,LEN(A2)),A2).
Checked by running on 2026-10-30: every formula and result on this page was calculated by the Spreadsheet Practice formula engine, in both Excel and Google Sheets modes.