String

2025/12/27

Type
Learning Resource
Format
Glossary Article
Version
General
Subject Tags
Code
Assets
All else
Copyright 2016-2026, GDQuest
Created
2026/02/16
Updated
2025/12/27

String

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.

Common string operations

There are many operations you can perform on strings:

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.

String comparison is case-sensitive

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 false

If 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.

Behind the scenes...

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.

Become an Indie Gamedev with GDQuest!

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.

Nathan

Founder and teacher at GDQuest
  • Starter Kit
  • Learn Gamedev from Zero
Check out GDSchool

You're welcome in our little community

Get help from peers and pros on GDQuest's Discord server!

20,000 membersJoin Server

Contribute to GDQuest's Free Library

There are multiple ways you can join our effort to create free and open source gamedev resources that are accessible to everyone!