# What is the general rule when using Text, String or Name?

**URL:** <https://forums.unrealengine.com/t/what-is-the-general-rule-when-using-text-string-or-name/292348>\
**Category:** UI\
**Tags:** string, text, unreal-engine, name, question\
**Created:** [August 29, 2014, 1:48pm UTC](https://forums.unrealengine.com/t/what-is-the-general-rule-when-using-text-string-or-name/292348 "2014-08-29T13:48:31Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_4071fa6e1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_4071fa6e1](https://forums.unrealengine.com/u/anonymous_user_4071fa6e1)\
**Post date:** [August 29, 2014, 1:48pm UTC](https://forums.unrealengine.com/t/what-is-the-general-rule-when-using-text-string-or-name/292348/1 "2014-08-29T13:48:31Z")

</div>

I know what each type does in principle, however, the [variables](https://www.youtube.com/watch?v=n-EQYeU5nZk&index=75&list=PLZlv_N0_O1gaCL2XjKluO7N2Pmmw9pvhE) tutorial skips any explanation of _Name_ and _Text_ variables in context of each. I have seen [this](https://docs.unrealengine.com/latest/INT/Programming/UnrealArchitecture/StringHandling/index.html) but it is isn’t that contextual.

Is there some general rule-of-thumb that can be applied when determining whether to use a **Text** , **Name** or **String** variable?

Should I always start with **Text** (for localisation) unless some factor forces a cast to another type?  
(e.g. a cast to a **String** where a Text variable is being compared or manipulated).

Could you give a simple example of where each variable type would be more appropriate than the others?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_48692ab5](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_48692ab5](https://forums.unrealengine.com/u/anonymous_user_48692ab5)\
**Post date:** [August 29, 2014, 5:07pm UTC](https://forums.unrealengine.com/t/what-is-the-general-rule-when-using-text-string-or-name/292348/2 "2014-08-29T17:07:48Z")

</div>

this is not an answer but an opinion. in my projects i use string for all of my variables unless it is used for variables i now is only going to be used for name (i.e. hitboxName). from there i just use my strings and cast to what i need them to be. sorry i couldnt give you an answer to your question but i hope this will at least get you by for the meantime :)!

---

<div class="post-metadata">

**Author:** ![Rama](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/rama/32/882413_2.png) [@Rama](https://forums.unrealengine.com/u/Rama)\
**Post date:** [August 29, 2014, 5:29pm UTC](https://forums.unrealengine.com/t/what-is-the-general-rule-when-using-text-string-or-name/292348/3 "2014-08-29T17:29:04Z")

</div>

#Data Type Size

Well I can tell you the following and you can answer your own question from there

FText is **40** bytes ~ (more than **2x** size of FString, more than **4x** the size of an FName)

FString is **16** bytes ~ ( **2x** size of FName, **4x** the size of a float/int32)

FName is **8** bytes ~ (smallest! Twice the size of a float/int32)

**So whenever you dont need the extra bytes you can use FName** , and you should only use FText for visible displayed text that actually matters to be different, region to region, thus requiring Localization.

Your internal naming scheme in code can be be FString or FName

Advantage of FString is all the handy functions in UnrealString.h

FString is the easiest type to manipulate, modify, search and replace, concatenate, etc etc.

**Strings you save to hard disk or send over the network should be FName to minimize data storage / data transfer**

Remember, with FName **you are sending half the bytes across the network** but you can still reconstruct into an FString on the other side!

Reconstruct an FName to FString like this:

```
YourFName.ToString()

```

convert FString to FName like this

```
FString Str = "Yay";
FName NewName = FName(*Str);

```

Enjoy!

Rama

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_4071fa6e1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_4071fa6e1](https://forums.unrealengine.com/u/anonymous_user_4071fa6e1)\
**Post date:** [August 29, 2014, 5:51pm UTC](https://forums.unrealengine.com/t/what-is-the-general-rule-when-using-text-string-or-name/292348/4 "2014-08-29T17:51:42Z")

</div>

Ok,

so (unless this is deemed technically incorrect by UE staff)  
my crude _rule-of thumb_ could be:

Use ‘ **Text** ’ variables where localised alpha-numeric display is required

Use ‘ **Name** ’ variables for alpha-numeric network sends/receives, or where a smaller memory footprint is desired

Use ‘ **String** ’ variables for all other alpha-numeric requirements, unless forced to cast, or if you know in advance that you will be using string manipulation functions

Thanks guys.

---

<div class="post-metadata">

**Author:** ![Shadow.Storm](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Shadow.Storm](https://forums.unrealengine.com/u/Shadow.Storm)\
**Post date:** [August 29, 2014, 6:30pm UTC](https://forums.unrealengine.com/t/what-is-the-general-rule-when-using-text-string-or-name/292348/5 "2014-08-29T18:30:44Z")

</div>

FNames are usually going to be an ID for something. They’re case-insensitive, which is probably the most important thing to remember about them.

- Asset names
- Material Parameters
- Tagging Actors
- Skeleton bone names

FText is generally what you want to use for anything that your users will see, even if you aren’t planning on localizing.

- Any text you show on a HUD
- When your player enters their name for a high score
- Calendar dates & times

FStrings do allow you to manipulate the variable value, like with reversing the string or taking a substring.

- Building a URL
- Creating a save file name

Do those examples help to clear things up? 🙂

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_4071fa6e1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_4071fa6e1](https://forums.unrealengine.com/u/anonymous_user_4071fa6e1)\
**Post date:** [August 29, 2014, 6:36pm UTC](https://forums.unrealengine.com/t/what-is-the-general-rule-when-using-text-string-or-name/292348/6 "2014-08-29T18:36:38Z")

</div>

Thanks Lauren, that does help.  
I wasn’t aware of the **FName** case-insensitivity.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_41948240](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_41948240](https://forums.unrealengine.com/u/anonymous_user_41948240)\
**Post date:** [May 15, 2015, 3:19pm UTC](https://forums.unrealengine.com/t/what-is-the-general-rule-when-using-text-string-or-name/292348/7 "2015-05-15T15:19:38Z")

</div>

I’ve got a question:  
Why should I use FText/FString/FName instead of good old std::string.  
Same thing for TArray and std::vector.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_e11ff324](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_e11ff324](https://forums.unrealengine.com/u/anonymous_user_e11ff324)\
**Post date:** [September 12, 2015, 11:40am UTC](https://forums.unrealengine.com/t/what-is-the-general-rule-when-using-text-string-or-name/292348/8 "2015-09-12T11:40:02Z")

</div>

Allocators, mostly.

---

<div class="post-metadata">

**Author:** ![Daekesh](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/daekesh/32/918652_2.png) [@Daekesh](https://forums.unrealengine.com/u/Daekesh)\
**Post date:** [December 16, 2015, 1:50am UTC](https://forums.unrealengine.com/t/what-is-the-general-rule-when-using-text-string-or-name/292348/9 "2015-12-16T01:50:16Z")

</div>

Sorry, Rama, but you’re really wrong on this one.

While the size of an FText, FString or FName may be those this is not how they are stored or replicated. It is the equivalent of saying a TArray variable is only 12 bytes when it has a million entries because its memory footprint is 12 bytes, so it’s only 12 bytes to store or replicate. I was told this is how you came to these numbers.

Now, I have no idea how much space it takes to replicate an FText (probably similar, but with some overheard,) but an FString will replicate the string length plus the string itself. So if it’s 2 characters long, you’ll get 3 bytes. If it’s a thousand characters long, it’ll be 1002 bytes (7-bit int encoding.) Double that if it’s 2-byte per character encoding. Or somewhere in between for unicode.

For FNames, they are sent over the network or serialized in 2 ways. Firstly, the few hard coded ones (see UnrealNames.inl) will be sent via a 7-bit int encoding (1-2 bytes.) The others are sent as plain text, exactly the same as FStrings.

---

<div class="post-metadata">

**Author:** ![HateDread](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@HateDread](https://forums.unrealengine.com/u/HateDread)\
**Post date:** [January 14, 2016, 4:13pm UTC](https://forums.unrealengine.com/t/what-is-the-general-rule-when-using-text-string-or-name/292348/10 "2016-01-14T16:13:26Z")

</div>

Bit late to the party, but don’t FNames replicate easier by having the ID pre-compiled on both ends? I.e. FName(“MyName”) will always have id 0, as an example, so replication will just say “FName(0)” or similar, and the other end will know that it means FName(“MyName”) without having to send across the plain text. This was just my guess, however - you obviously have looked at it more closely. I just want to double-check 🙂

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_478829031](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_478829031](https://forums.unrealengine.com/u/anonymous_user_478829031)\
**Post date:** [January 29, 2016, 9:48pm UTC](https://forums.unrealengine.com/t/what-is-the-general-rule-when-using-text-string-or-name/292348/11 "2016-01-29T21:48:38Z")

</div>

While Rama’s answer is mostly correct **you should NOT use FName to save to disk nor send it across the network for communication.**

To quote staff user: [https://answers.unrealengine.com/users/1232/gmpreussner.html](https://answers.unrealengine.com/users/1232/gmpreussner.html)  
from: [FNames under the hood - Programming & Scripting - Epic Developer Community Forums](https://answers.unrealengine.com/questions/97168/fnames-under-the-hood-epic.html)

> Note that you should not store FNames  
> on disk or serialize them over the  
> network. They are guaranteed to be  
> unique only within the local process  
> (not even on the same machine). When  
> persisting or serializing FName  
> fields, convert them from and to  
> FString instead.

---

<div class="post-metadata">

**Author:** ![FunAndFriendly](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@FunAndFriendly](https://forums.unrealengine.com/u/FunAndFriendly)\
**Post date:** [April 16, 2021, 1:51pm UTC](https://forums.unrealengine.com/t/what-is-the-general-rule-when-using-text-string-or-name/292348/12 "2021-04-16T13:51:22Z")

</div>

FName

- immutable
- case-insensitive
- useful for ids.

FText

- immutable
- case-sensitive
- useful for writing static content that will be “localized” - e.g. translating a game to another language

FString

- mutable
- has standardish function library.
- useful for dynamically manipulating text at runtime.

---

<div class="post-metadata">

**Author:** ![stereocode](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/stereocode/32/964066_2.png) [@stereocode](https://forums.unrealengine.com/u/stereocode)\
**Post date:** [August 15, 2024, 7:12pm UTC](https://forums.unrealengine.com/t/what-is-the-general-rule-when-using-text-string-or-name/292348/13 "2024-08-15T19:12:49Z")

</div>

I know this thread is old but it came up in google search when trying to figure out how long strings can be used in UE.

One important thing to note about **FText is that it can be used to reference String Tables**. which is the uasset type for making large bodies of text. This is key when making structs and data table assets in the editor.
