FormulaCraft

How to pad numbers with leading zeros in Excel and Google Sheets

Topic:Text manipulation
Excel & Google Sheets
=RIGHT("00000"&A2, 5)

Verified example

Computed by a real spreadsheet engine on the sample data below.

ID
42

=RIGHT("00000"&A2, 5)00042

Try it with your data

Edit the grid or formula, then run it through a real spreadsheet engine — no signup.

Sample data — click any cell to edit

Runs server-side · free · no signup

Step by step

  1. 1"00000"&A2 sticks five zeros in front of the number.
  2. 2RIGHT(…,5) keeps only the last 5 characters.
  3. 342 becomes "00042"; change the width by adjusting both 5s.

Tips

Need it for your exact data?

Describe your columns in plain English and get the precise formula for your sheet, with the right Excel or Sheets syntax.

Frequently asked

Why do my leading zeros disappear when I type them?

Spreadsheets drop leading zeros from numbers. Store the value as text, or build it with this formula.

More on Text manipulation

See all →

Formulas used

Written and reviewed by FormulaCraft Team. Each formula on this page is run through our verification engine before publishing.

Last reviewed: