You can remove the first character of a string using substring:

var s1 = "foobar";
var s2 = s1.substring(1);
alert(s2); // shows "oobar"

To remove all 0's at the start of the string:

var s = "0000test";
while(s.charAt(0) === '0')
{
 s = s.substring(1);
}
Answer from Shaded on Stack Overflow
Top answer
1 of 16
1363

You can remove the first character of a string using substring:

var s1 = "foobar";
var s2 = s1.substring(1);
alert(s2); // shows "oobar"

To remove all 0's at the start of the string:

var s = "0000test";
while(s.charAt(0) === '0')
{
 s = s.substring(1);
}
2 of 16
254

Very readable code is to use .substring() with a start set to index of the second character (1) (first character has index 0). Second parameter of the .substring() method is actually optional, so you don't even need to call .length()...

TL;DR : Remove first character from the string:

str = str.substring(1);

...yes it is that simple...

Removing some particular character(s):

As @Shaded suggested, just loop this while first character of your string is the "unwanted" character...

var yourString = "0000test";
var unwantedCharacter = "0";
//there is really no need for === check, since we use String's charAt()
while( yourString.charAt(0) == unwantedCharacter ) yourString = yourString.substring(1);
//yourString now contains "test"

.slice() vs .substring() vs .substr()

EDIT: substr() is not standardized and should not be used for new JS codes, you may be inclined to use it because of the naming similarity with other languages, e.g. PHP, but even in PHP you should probably use mb_substr() to be safe in modern world :)

Quote from (and more on that in) What is the difference between String.slice and String.substring?

He also points out that if the parameters to slice are negative, they reference the string from the end. Substring and substr doesn´t.

🌐
GeeksforGeeks
geeksforgeeks.org › javascript › delete-first-character-of-a-string-in-javascript
JavaScript - Delete First Character of a String - GeeksforGeeks
To delete the first character of a string in JavaScript, you can use several methods. Here are some of the most common ones · The slice() method is frequently used to remove the first character by returning a new string from index 1 to the end.
Published: July 11, 2025
Discussions

How to remove first and last character of a string?
So I am using formatted as JSON safe and it adds " char on the start and end of string which is causing me errors, I dont want to find and replace all " characters but instead remove just the " on the first and last of the string. More on forum.bubble.io
🌐 forum.bubble.io
5
0
January 22, 2022
jquery - the best way to remove the first char of a given string in javascript - Stack Overflow
Using jquery, underscore or pure javascript what is the best way to remove the first char of a given string? ... Um... that is the best way. What is wrong with that approach? Could be wrapped in a function if you do it a lot. ... Save this answer. ... Show activity on this post. ... Save this answer. ... Show activity on this post. ... If indexB is omitted, substring extracts characters ... More on stackoverflow.com
🌐 stackoverflow.com
Remove the first character from a string
Hi, It’s common to remove the first character of a string by typing a[1:] for a string. I was wondering why it also works for a single-character string? a = 'x' a[1:] '' a[1] Traceback (most recent call last): File " More on discuss.python.org
🌐 discuss.python.org
2
1
March 10, 2022
Remove first or last element of a string
I have a string “1 Professional Services” which I want to remove “1” from it and output = “Professional Services” I have a string “Professional Services 1” which I want to remove “1” from it and output = “Professional Services” Help More on forum.uipath.com
🌐 forum.uipath.com
3
0
March 29, 2023
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › String › substring
String.prototype.substring() - JavaScript | MDN
The index of the first character to exclude from the returned substring. A new string containing the specified part of the given string.
🌐
Bubble
forum.bubble.io › need help
How to remove first and last character of a string? - Need help - Bubble Forum
January 22, 2022 - So I am using formatted as JSON safe and it adds " char on the start and end of string which is causing me errors, I dont want to find and replace all " characters but instead remove just the " on the first and last of the string.
🌐
Flavio Copes
flaviocopes.com › home › javascript › how to remove the first character of a string in javascript
How to remove the first character of a string in JavaScript
April 21, 2020 - To remove the first character of a string in JavaScript, call the slice() method on the string, passing 1 as the argument:
Find elsewhere
🌐
Medium
frontend-developer.medium.com › javascript-how-to-remove-the-first-characters-of-a-string-e3f02440b608
JavaScript — How to Remove the first characters of a string - deepak chandra - Medium
November 18, 2020 - Now, we want to remove the first 2 characters vol from the above string. ... To remove the first n characters of a string in JavaScript, we can use the built-in slice() method by passing the n as an argument.
🌐
ServiceNow Community
servicenow.com › community › common-service-data-model-forum › remove-first-character-from-a-table-s-field › td-p › 2368553
Solved: Remove first character from a table's field - ServiceNow Community
December 19, 2023 - Very helpful article! The .substring(#) method can be used to remove character from the beginning of a string. I used it in my business rule below.
🌐
GitHub
github.com › stdlib-js › string-remove-first
GitHub - stdlib-js/string-remove-first: Remove the first character of a string. · GitHub
Appropriate for strings containing visual characters drawn from the basic multilingual plane (BMP) (e.g., common characters, such as those from the Latin, Greek, and Cyrillic alphabets). Default: 'grapheme'. By default, the function returns the first character. To return the first n characters, provide a second argument specifying the number of characters to return. var out = removeFirst( 'foo bar', 4 ); // returns 'bar' out = removeFirst( 'foo bar', 10 ); // returns ''
Author: stdlib-js
🌐
Python.org
discuss.python.org › python help
Remove the first character from a string - Python Help - Discussions on Python.org
March 10, 2022 - Hi, It’s common to remove the first character of a string by typing a[1:] for a string. I was wondering why it also works for a single-character string? a = 'x' a[1:] '' a[1] Traceback (most recent call last): File " ", line 1, in IndexError: ...
🌐
UiPath Community
forum.uipath.com › help › studio
Remove first or last element of a string - Studio - UiPath Community Forum
March 29, 2023 - I have a string “1 Professional Services” which I want to remove “1” from it and output = “Professional Services” I have a string “Professional Services 1” which I want to remove “1” from it and output = “Professional S…
🌐
CSS-Tricks
css-tricks.com › snippets › javascript › trim-firstlast-characters-in-string
Trim First/Last Characters in String | CSS-Tricks
September 2, 2014 - @alankar, I would copy and store the original value in a data-attribute and then mask all but the total length of the string minus 3 by using regex to replace the characters with the asterisk character. Yell if you need further help! ... var myString = "abcdefghijklmnopqrstuvwxyz"; var firstString = myString.substr(0, myString.length - 5); maskString = firstString.replace(/[a-zA-Z0-9]/g, '*'); var lastString = myString.substr(myString.length - 5); var newString = maskString.concat(lastString); document.write("1st: " + firstString); document.write("<br/>"); document.write("2nd: " + lastString); document.write("<br/>"); document.write("3rd: " + newString);
🌐
W3Schools
w3schools.com › jsref › jsref_slice_string.asp
JavaScript String slice() Method
More examples below. The slice() method extracts a part of a string. The slice() method returns the extracted part in a new string. The slice() method does not change the original string.
🌐
Arshad Mehmood
arshadmehmood.com › home › today i learned › javascript
Trim/Remove first or last character in Javascript - Arshad Mehmood
Business Informatics from University of Mannheim. Building scalable solutions and sharing knowledge. ... While using C#, if you want to remove the first character or the last character then you can simply use one of the following lines of code: //Trim start string trimmed = str.TrimStart('?', '.', ','); //Trim End string trimmed1 = str.TrimEnd('?', '.', ','); //Trim start single character string trimsingle = str.TrimStart('?'); Javascript’s trim method doesn’t accept any paramters.
🌐
Tutorial Republic
tutorialrepublic.com › faq › how-to-remove-first-character-from-a-string-in-jquery.php
How to Remove First Character from a String in jQuery
You can use the JavaScript substring() method to remove first character form a string. A typical example is removing hash (#) character from fragment identifier.
🌐
Wapgee
wapgee.com › web-development › removing-first-occurrence-from-a-string-in-javascript-241
Removing first occurrence from a string in JavaScript - Wapgee
September 6, 2022 - One of the most effective ways of removing the first occurrence from a string is by converting and splitting the string into an array, then you can use the shift() function to remove the very first character from the string.
🌐
W3Schools
w3schools.com › jsref › jsref_trim_string.asp
JavaScript String trim() Method
The trim() method does not change the original string. ... Coding fundamentals as a game. Bite-sized lessons and challenges. ... Ready to start your journey? Your streak is waiting.
🌐
GeeksforGeeks
geeksforgeeks.org › php › how-to-remove-the-first-character-of-string-in-php
How to remove the first character of string in PHP? - GeeksforGeeks
July 11, 2025 - In PHP to remove characters from the beginning we can use ltrim but in that, we have to define what we want to remove from a string i.e.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › String › trimStart
String.prototype.trimStart() - JavaScript | MDN
July 10, 2025 - The trimStart() method of String values removes whitespace from the beginning of this string and returns a new string, without modifying the original string. trimLeft() is an alias of this method.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › String › charAt
String.prototype.charAt() - JavaScript | MDN
The charAt() method of String values returns a new string consisting of the single UTF-16 code unit at the given index.