How to Capitalize First Letter of String in Laravel?

By Hardik Savani November 5, 2023 Category : Laravel

Hey Folks,

This tutorial will give you an example of laravel string capitalize. We will use laravel capitalize first letter. This article will give you a simple example of how to capitalize first letter in laravel. you'll learn how to capitalize string in laravel. follow the below example for laravel str::ucfirst() helper example.

The Str::ucfirst() method in Laravel is used to make the first character of a string uppercase. It is a convenient method to capitalize the first character of a string.

Here's an example of how to use it:

In this example, the Str::ucfirst() method is applied to the $string variable, and it returns a new string with the first character capitalized. The resulting string is then echoed, displaying "Laravel is awesome".

let's see the simple example:

Laravel Capitalize First Letter of String in Controller

you can use it with controller like this way:

Controller Code:


namespace App\Http\Controllers;

use Illuminate\Http\Request;

use Illuminate\Support\Str;

class UserController extends Controller



* Display a listing of the resource.


* @return \Illuminate\Http\Response


public function index(Request $request)


$string = 'laravel is awesome';

$ucfirstString = Str::ucfirst($string);





Laravel is awesome

Laravel Capitalize First Letter of String in Blade File

you can use it with blade file like this way:

Blade File Code:

<p>{{ Str::ucfirst("laravel is awesome") }}</p>


Laravel is awesome

I hope it can help you...

Tags :