Skip to content
Google Sheets

CODE function in Google Sheets

Returns the numeric Unicode map value of the first character in the string provided.

=CODE(string)

CODE syntax and parameters

One argument, one required.

  • stringstringRequired

    The string whose first character's Unicode map value will be returned.

CODE examples

Formulas you'll actually reuse.

  1. The code of the first character — 32 means a hidden leading space:

    =CODE(A2)

    Result32

  2. Check the last character — 160 is a non-breaking space that TRIM won't remove:

    =CODE(RIGHT(A2, 1))

    Result160

CODE in Excel

Same name — your formula ports as-is.

Try CODE in the playground

Edit the example — nothing to install.

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

Loading the editor…