How to create a URL slug from a title in Excel
Excel formula
=LOWER(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(TRIM(A2),":",""),"?",""),",",""),"'",""),"!","")," ","-"))Trim the title, remove punctuation with SUBSTITUTE, turn spaces into hyphens and make it lowercase: =LOWER(SUBSTITUTE(…TRIM(A2)…," ","-")).
- Result on the example
- one result per row in
B2, filled down toB7 - Works in
- Microsoft 365 only
- Google Sheets
- Different formula, see below
See it work
The formula is already in B2, filled down to B7. Change any input and the result updates, or edit the formula to experiment.
How it works
Work from the inside out: TRIM removes stray spaces, each SUBSTITUTE deletes one punctuation mark (: ? , ' !), the last SUBSTITUTE turns spaces into hyphens, and LOWER makes it all lowercase.
Google Sheets can do it with patterns: the first REGEXREPLACE deletes anything that isn't a letter, digit or space, the second turns runs of spaces into one hyphen. Excel 365 now has REGEXREPLACE too, and the same formula works there.
=LOWER(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(TRIM(A2),":",""),"?",""),",",""),"'",""),"!","")," ","-"))Result"how-to-track-expenses-in-2026"
A2"How to Track Expenses in 2026"The value in A2.
TRIM(A2)"How to Track Expenses in 2026"TRIM: Removes extra spaces, leaving single spaces between words.- text
A2"How to Track Expenses in 2026"
- text
SUBSTITUTE(TRIM(A2),":","")"How to Track Expenses in 2026"SUBSTITUTE: Replaces matching text.- text
TRIM(A2)"How to Track Expenses in 2026" - old_text
":" - new_text
""
- text
SUBSTITUTE(SUBSTITUTE(TRIM(A2),":",""),"?","")"How to Track Expenses in 2026"SUBSTITUTE: Replaces matching text.- text
SUBSTITUTE(TRIM(A2),":","")"How to Track Expenses in 2026" - old_text
"?" - new_text
""
- text
SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(TRIM(A2),":",""),"?",""),",","")"How to Track Expenses in 2026"SUBSTITUTE: Replaces matching text.- text
SUBSTITUTE(SUBSTITUTE(TRIM(A2),":",""),"?","")"How to Track Expenses in 2026" - old_text
"," - new_text
""
- text
SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(TRIM(A2),":",""),"?",""),",",""),"'","")"How to Track Expenses in 2026"SUBSTITUTE: Replaces matching text.- text
SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(TRIM(A2),":",""),"?",""),",","")"How to Track Expenses in 2026" - old_text
"'" - new_text
""
- text
SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(TRIM(A2),":",""),"?",""),",",""),"'",""),"!","")"How to Track Expenses in 2026"SUBSTITUTE: Replaces matching text.- text
SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(TRIM(A2),":",""),"?",""),",",""),"'","")"How to Track Expenses in 2026" - old_text
"!" - new_text
""
- text
SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(TRIM(A2),":",""),"?",""),",",""),"'",""),"!","")," ","-")"How-to-Track-Expenses-in-2026"SUBSTITUTE: Replaces matching text.- text
SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(TRIM(A2),":",""),"?",""),",",""),"'",""),"!","")"How to Track Expenses in 2026" - old_text
" " - new_text
"-"
- text
LOWER(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(TRIM(A2),":",""),"?",""),",",""),"'",""),"!","")," ","-"))"how-to-track-expenses-in-2026"LOWER: Converts to lowercase.- text
SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(TRIM(A2),":",""),"?",""),",",""),"'",""),"!","")," ","-")"How-to-Track-Expenses-in-2026"
- text
In Google Sheets
Google Sheets needs a different formula: =LOWER(REGEXREPLACE(REGEXREPLACE(TRIM(A2),"[^A-Za-z0-9 ]","")," +","-")). On the same data it gives the same result. Here it is running in Google Sheets mode.
Other ways to do it
Each one was run on the same example sheet.
| Formula | Result | When to use it |
|---|---|---|
| =LOWER(SUBSTITUTE(TRIM(LET(c,MID(A2,SEQUENCE(LEN(A2)),1),CONCAT(IF(ISNUMBER(FIND(LOWER(c),"abcdefghijklmnopqrstuvwxyz0123456789 ")),c,""))))," ","-")) | how-to-track-expenses-in-2026, q3-sales-what-changed, ten-tips-for-remote-teams… | Excel 365: splits the title into characters and keeps only letters, digits and spaces, so any punctuation is removed, not just the marks you listed. |
Common mistakes
- Punctuation between spaces, as in "Sales - Q3", leaves a double space and so a double hyphen. TRIM after removing punctuation, not only before.
- Accented letters (é, ü) pass through. Replace them with SUBSTITUTE if your site needs plain ASCII slugs.
- Two titles can produce the same slug. Check with
=COUNTIF($B$2:$B$7,B2)>1.
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.
Create a URL slug from a title
B2, turn the title into a URL slug: lowercase, no punctuation, words joined by hyphens. Fill down to B7.Questions
How do I limit a slug to 60 characters without cutting a word?
Cut at 60, then back to the last hyphen: =IF(LEN(B2)>60,TEXTBEFORE(LEFT(B2,61),"-",-1),B2).
How do I build the full URL?
Join the slug to the base address: ="https://example.com/blog/"&B2.
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.