You can use the substring function:

let str = "12345.00";
str = str.substring(0, str.length - 1);
console.log(str);
Run code snippetEdit code snippet Hide Results Copy to answer Expand

This is the accepted answer, but as per the conversations below, the slice syntax is much clearer:

let str = "12345.00";
str = str.slice(0, -1); 
console.log(str);
Run code snippetEdit code snippet Hide Results Copy to answer Expand

Neither method mutates

Answer from Jon Erickson on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-program-to-remove-first-and-last-characters-from-a-string
JavaScript- Remove Last Characters from JS String - GeeksforGeeks
July 23, 2025 - The slice() method returns a part of a string by specifying the start and end indices. To remove the last character, we slice the string from the start (index 0) to the second-to-last character.
🌐
Mastering JS
masteringjs.io › tutorials › fundamentals › remove-last-character
How to Remove the Last Character from a String in JavaScript - Mastering JS
November 12, 2021 - Using /.$/ as the regular expression argument matches the last character of the string, so .replace(/.$/, '') replaces the last character of the string with an empty string.
🌐
Linux Hint
linuxhint.com › remove-second-last-character-from-string-javascript
Linux Hint – Linux Hint
Linux Hint LLC, [email protected] 1210 Kelly Park Circle, Morgan Hill, CA 95037 Privacy Policy and Terms of Use
🌐
Medium
medium.com › @ryan_forrester_ › javascript-remove-last-character-from-string-fc1cabdf2722
Javascript Remove Last Character From String | by ryan | Medium
September 10, 2024 - If your strings include multi-byte Unicode characters (such as emojis), removing the last character might require special handling. JavaScript’s string methods don’t natively account for Unicode character length, which can result in incorrect behavior.
🌐
Flavio Copes
flaviocopes.com › home › javascript › how to remove the last character of a string in javascript
How to remove the last character of a string in JavaScript
April 20, 2020 - A negative end counts from the end of the string. Passing -1 means “stop one character before the end”, which drops the last character. Passing -2 drops the last two:
🌐
Reactgo
reactgo.com › home › remove the last 2 characters of a string in javascript
Remove the last 2 characters of a string in JavaScript | Reactgo
June 23, 2023 - Similarly, we can use the substring() method in JavaScript to remove the last 2 characters of a given string. ... Note: The substring() method also works similar like slice method but in substring() method if first argument index is greater ...
Find elsewhere
🌐
CoreUI
coreui.io › blog › how-to-remove-the-last-character-from-a-string-in-javascript
How to Remove the Last Character from a String in JavaScript · CoreUI
June 23, 2024 - Removing the last character from a string in JavaScript is a common task, whether you’re dealing with user input or formatting strings. JavaScript provides several methods to achieve this, including slice(), substring(), and replace(). This ...
🌐
TecAdmin
tecadmin.net › remove-last-character-from-string-in-javascript
2 Methods to Remove Last Character from String in JavaScript – TecAdmin
April 26, 2025 - Use the substring() function to remove the last character from a string in JavaScript.
🌐
PrintMyFonts
askingbox.com › tip › javascript-remove-last-character-from-string
JavaScript: Remove last character from string
In this article I want to show you how you can remove the last character from any string with the help of JavaScript. Before I start with the explanations, let's first take a look at the code required for this. Here is how to do it: var str_old = '1,2,3,'; var str_new = str_old.substr(0, ...
🌐
Stack Abuse
stackabuse.com › bytes › trim-the-last-n-characters-from-a-string-in-javascript
Trim the Last N Characters from a String in JavaScript
August 21, 2023 - JavaScript has quite a few methods to manipulate strings. One of those methods involves trimming the last N characters from a string. This Byte will show you two ways to achieve this: using the String.substring() method and conditionally removing the last N characters.
🌐
Bobby Hadz
bobbyhadz.com › blog › javascript-remove-last-n-characters-from-string
Remove the last N Characters from a String in JavaScript | bobbyhadz
March 1, 2024 - Copied!const str = 'bobbyhadz.com'; // ✅ Remove the last 2 characters from a string const removeLast2 = str.slice(0, -2); console.log(removeLast2); // 👉️ bobbyhadz.c // ✅ Remove the last 3 characters from a string const removeLast3 ...
🌐
Byby
byby.dev › js-remove-last-char
How to remove last character from string in JavaScript
By replacing it with an empty string, that character is removed. Please note that if the string contains newline characters or multiple Unicode code points, the regular expression approach may not behave as expected.
🌐
EyeHunts
tutorial.eyehunts.com › home › remove the last 2 character from the string javascript | code
Remove the last 2 character from the string JavaScript | Code
May 20, 2024 - Use the slice() method with 0 for the start index and -2 the end index as parameters to Remove the last 2 characters from the string in JavaScript.
🌐
Scaler
scaler.com › home › topics › remove last character from string in javascript
Remove the Last Character from a String in JavaScript - Scaler Topics
May 4, 2023 - Using substring() method substring() method in javascript is used to extract and return a desired part of string and by using this we can remove last character from string javascript. The substring() method takes two parameters in general, the first parameter is the starting index and the second ...
🌐
Coderslang
learn.coderslang.com › 0030-javascript-remove-last-character-from-a-string
JavaScript, remove last character from a string - Coderslang
February 14, 2021 - const base = 'javascript, remove last char!' const s = base.slice(0, -1); console.log(s); // javascript, remove last char · The function slice returns a part of the string. We pass in two values, start and end. Eventually slice returns us a substring of base between start and end. If end is a negative number, the lookup begins from the end of the string. ... As the function slice only returns us a substring and doesn’t mutate the original string, we can use the function substring to get the same outcome.
🌐
Medium
medium.com › @onlinemsr › how-to-remove-the-last-character-from-a-string-in-javascript-3d1c238d1669
How to Remove the Last Character from a String in JavaScript | by Raja MSR | Medium
February 15, 2024 - Removing the last character from a string can be tricky, as there are different methods and scenarios to consider. ... By the end of this blog post, you will have a better understanding of how to use JavaScript to remove the last character from a string, and how to apply this skill to various situations.
🌐
Reddit
reddit.com › r/learnjavascript › removing the first and last character from a .json file.
r/learnjavascript on Reddit: Removing the first and last character from a .JSON file.
May 3, 2021 -

I am just making sure I am thinking about this correctly,

I have a .JSON file and it looks like this example

[{title: "title"}]

And I need it to be {title: "title"}

So my idea is like, read the file then do some stuff then write a new file..

const fs = require('fs')

fs.readFile('./test.json', 'utf8' , (err, data) => {
  if (err) {
    console.error(err)
    return
  }
  var result = data.substring(1, data.length-1);
})


 fs.writeFile("finalOutput.json", JSON.stringify(result), function (err) {
    if (err) return console.log(err);
    return console.log("done");
  });

Something like this maybe wrapping the first one in a promise.

Does this make sense? Is there a better way?

🌐
Coderslang
learn.coderslang.com › 0179-how-to-remove-the-last-n-characters-from-a-javascript-string
How to remove the last n characters from a JavaScript string
January 24, 2022 - Before you make another step, remember, that strings in JavaScript are immutable. This means that you can’t alter the string by removing something from it. So, when you want to remove the last n symbols from a string in JS, your only option is to create a new string that wouldn’t have these ...
🌐
Techie Delight
techiedelight.com › home › java › remove last character from a string in javascript
Remove last character from a string in JavaScript | Techie Delight
July 7, 2026 - This post will discuss how to remove the last character from a string in JavaScript using the `substring()`, `slice()`, or `substr()` method.