How to convert text to dash-case in Google Sheets

Ever struggled with exporting your Google Search Console keywords and converting them to the format required by URLs (dash-case)? Google sheets can help you with converting these keywords to the URL format.

Segun Adebayo

Kevin Peters

6/3/2021

Google SheetsTutorial
A banner that shows case converter extension with an error to caseConverterExtension

So let us start with explaining which tools we are going to use. Since this tutorial is focused on Google Sheets I assume you have a Google account with access to Google sheets. You can simply create a Google Drive account and should be set up then. Then simply create a new Google Spreadsheet.

A google spreadsheet that is empty

Now we have to fill the spread sheet with data. For that we can use several data sources. Ideally you should use your own or even have data in your spreadsheet already. For an easy way to follow this tutorial simply copy the following list items and insert them into the spreadsheet:

  • case converter extension
  • case converter near me
  • case converter chrome extension
  • case converter transformation in informatica
  • case converter in excel
  • case converter textmagic
  • case converter download
  • case converter html
  • case converter visual studio
  • title case converter
  • upper case converter
  • camel case converter
  • title case converter online
  • snake case converter
  • alternating case converter
  • kebab case converter
  • pascal case converter
  • camel case to snake case converter
  • random case converter
  • cassette converter
  • case sensitive converter
  • cassette to mp3 converter
  • case 450 dozer torque converter
  • cassette tape converter
  • casey horner catalytic converter
  • case 580k torque converter
  • cassette to digital converter
  • case sentence converter
  • case title converter
The google spreadsheet with the example data mentioned above

So now we can actually work on the data. Now we will work on column B. Google Sheets supports the LOWER() and UPPER() functionality. These work kind of similar to what we want to achieve. Just that there need to be a function called DASH_CASE().

For this use case we need to extend Google Sheets though. This requires some programming but do not fear back. This article is written for everyone, even if you do not have any programming experience. Google supports something called the Script editor which we will open now. For that, go to the menu bar, click on Tools and then on Script Editor.

Menu opened in Google spreadsheets showin the script editor

This should open a new tab. Do not scare back yet! The first thing you should do is to delete all the code in the script section so it looks like the following:

The script editor interface

Now its time to code! Or as we say, just copy paste some snippets we have prepared for you. You can copy and paste the following code into the script window.

1function DASH_CASE(str) {
2  return str
3    .match(/[A-Z]{2,}(?=[A-Z][a-z0-9]*|\b)|[A-Z]?[a-z0-9]*|[A-Z]|[0-9]+/g)
4    .filter(Boolean)
5    .map(x => x.toLowerCase())
6    .join("-");
7}
8

The script window should look like the following then:

The script editor with the pasted code

Now it is time to press the save icon on top of the code. Alternatively you can press CTRL + S (CMD + S on Mac) to save the script and then we can head back to the Google Sheet. Reload the page once. Ideally with CTRL + R (CMD + R on Mac). And select the field B1.

As with the LOWER() function we can use the DASH_CASE() function now. Simply type the following into the field B1: =DASH_CASE(A1)

Applying the custom DASH_CASE function to the spread sheet

And this results in the following value of the column: case-converter-extension. So now we can also apply the function to all rows. You can do that by simply dragging the bottom right corner of field B1 to the bottom. You can also see it in the GIF below.

Applying the DASH_CASE function to all rows

So this should have brought you to your goal. Feel free to share this article with your colleagues and if you have any feedback feel free to reach out to us.

More from caseconverter.pro

  • some text
    Google SheetsTutorial

    How to convert text to dash-case in Google Sheets

    Ever struggled to generate URL slugs from a long list of words in Google Sheets or Microsoft Excel? Not with our guide. Learn how to write a custom function to change the case style to dash-case, also known as kebab- or hyphen-case.

    Segun Adebayo

    Kevin Peters

    6/3/2021

  • some text
    JavaScriptTutorialcamelCase

    How to convert any string to camelCase in JavaScript

    Converting a string to camelCase in JavaScript (JS) can be quite tricky with all edge cases. This blog will show you how to handle the edge cases and even converting object keys.

    Segun Adebayo

    Kevin Peters

    5/6/2021

  • some text
    JavaScriptTutorialEngineering

    How to change JSON keys in JavaScript

    Changing the keys in objects in JavaScript objects is sometimes required. JavaScript mostly works with camelCase and transforming other case types is really helpful to make linters happy.

    Segun Adebayo

    Kevin Peters

    4/11/2021

  • some text
    kebab-caseInformation

    What's the name for hyphen-separated case?

    For the hyphen-separated case there are multiple names: kebab-case, hyphen-case, slug-case and many other options... But what is the right one to choose. This article will help you to make a decision.

    Segun Adebayo

    Kevin Peters

    3/17/2021

  • some text
    EngineeringTechnology

    Why we love our tech stack

    The reasons why we love our technology stack at caseconverter.pro are quite diverse. Read it here and gather insightful statistics about which technologies were used and why you should use them too.

    Segun Adebayo

    Kevin Peters

    1/19/2020

This site is using cookies to personalize content and adverts, to provide social media features and to analyse traffic.