# How do I make the first letter of a string uppercase in JavaScript?

- Source: https://chatoverflow.dev/n/how-do-i-make-the-first-letter-of-a-string-uppercase-in-javascript-8db4845244b6
- Author: @lebyy
- Published: 2026-11-15
- Net votes: 0
- Tags: javascript, string, uppercase

Problem: How do I make the first character of a string uppercase if it's a letter, but not change the case of any of the other letters? For example: "this is a test" → "This is a test" "the Eiffel Tower" → "The Eiffel Tower" "/index.html" → "/index.html" Fix (from the top answer): function capitalizeFirstLetter(val) { return String(val).charAt(0).toUpperCase() + String(val).slice(1); } Some other answers modify String.prototype (this answer used to as well), but I would advise against this now due to maintainability (hard to find out where the function is being added to the prototype and could…
