String
2025/12/27
- Type
- Learning Resource
- Format
- Glossary Article
- Version
- General
- Subject Tags
- Created
- Updated
- 2026/02/16
- 2025/12/27
A string is a sequence of characters (like 'a', 'b', '!') that represents text. In GDScript, we write strings by wrapping text in either single quotes, double quotes, or triple double quotes. The following three examples are all equivalent:
var string_1 := "Hello, Godot!"
var string_2 := 'Hello, Godot!'
var string_3 := """Hello, Godot!"""Strings can contain letters, numbers, symbols, and spaces: "Hello, Godot!", '250', and "@$%!" are all valid strings. Even an empty pair of quotes works: "" is called an empty string. It's an empty sequence of characters.
We use strings for all our text needs in code:
And so on.
There are many operations you can perform on strings:
"Hello " + "World" produces "Hello World".length() method to get the number of characters in a string. "Hello".length() produces 5. You can use this to calculate the duration of a text appearance animation or how much space a text will take on the screen.replace() method to replace a substring with another. "Hodot".replace("H", "G") produces "Godot".capitalize() method to capitalize the first letter of a string. "godot".capitalize() produces "Godot".There are many more operations that you can find by browsing the code reference in Godot: Go to Help -> Search Help... or press f1 (on Mac: ⌥space) on your keyboard.
When comparing strings using the equality operator (==), the computer checks if the strings match exactly, including uppercase and lowercase letters:
"hello" == "hello" is true"Hello" == "hello" is falseIf you need to compare strings ignoring case, most programming languages provide special methods. In Godot, you can call String.to_lower() to convert a string to lowercase before comparing it.
In some programming languages, there's a distinction between a single character and a string containing one character.
For the computer, strings don't really exist: A string is an array of individual characters. In the C programming language, a language close to how the computer works, you could think of the string "Hello" like this: the array ['H', 'e', 'l', 'l', 'o', '\0'], where each value is a character. The last character, \0, is a special value that marks the end of the string. It's called the "null terminator."
In GDScript, and in many modern languages, there isn't a separate character type. Instead, a single character is a string of length 1.
Don't stop here. Step-by-step tutorials are fun but they only take you so far.
Try one of our proven study programs to become an independent Gamedev truly capable of realizing the games you’ve always wanted to make.
Get help from peers and pros on GDQuest's Discord server!
20,000 membersJoin ServerThere are multiple ways you can join our effort to create free and open source gamedev resources that are accessible to everyone!
Sponsor this library by learning gamedev with us onGDSchool
Learn MoreImprove and build on assets or suggest edits onGithub
Contributeshare this page and talk about GDQUest onRedditYoutubeTwitter…