Spreadsheet Practice

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 to B6
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"

  1. A2"chair, desk, lamp,"

    The value in A2.

  2. RIGHT(A2)","

    RIGHT: Characters from the end of text.

    • textA2"chair, desk, lamp,"
  3. RIGHT(A2)=","TRUE

    The = operator tests whether the two sides are equal.

  4. LEN(A2)18

    LEN: Number of characters.

    • textA2"chair, desk, lamp,"
  5. LEN(A2)-117

    The - operator subtracts.

  6. LEFT(A2,LEN(A2)-1)"chair, desk, lamp"

    LEFT: Characters from the start of text.

    • textA2"chair, desk, lamp,"
    • num_charsLEN(A2)-117
  7. 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_testRIGHT(A2)=","TRUE
    • value_if_trueLEFT(A2,LEN(A2)-1)"chair, desk, lamp"
    • value_if_falseA2"chair, desk, lamp,"not used

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.

FormulaResultWhen 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 Sheetschair, 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

In 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.