Skip to content
Google Sheets

REPLACE function in Google Sheets

Replaces part of a text string with a different text string.

=REPLACE(text, position, length, new_text)

REPLACE syntax and parameters

Four arguments, four required.

  • textstringRequired

    The text, a part of which will be replaced.

  • positionnumberRequired

    The position where the replacement will begin (starting from 1).

  • lengthnumberRequired

    The number of characters in the text to be replaced.

  • new_textstringRequired

    The text which will be inserted into the original text.

REPLACE examples

Formulas you'll actually reuse.

  1. Mask the first four characters of an account number:

    =REPLACE(A2, 1, 4, "XXXX")

    Result"XXXX5678"

  2. Swap the domain after the @ in an email address:

    =REPLACE(A2, FIND("@", A2) + 1, LEN(A2), "newdomain.com")

    Result"maria.lopez@newdomain.com"

REPLACE in Excel

Same name — your formula ports as-is.

Try REPLACE in the playground

Edit the example — nothing to install.

Preloaded with the REPLACE formula from Example 1 — change anything and watch it respond.

Loading the editor…