Beginner's guide: Text blocks

This is purely a beginner’s tutorial.

I will show the things you can do with the different text blocks.

This is a textstring block


Default it is empty but you can fill it with a lot of different things. Some samples you can find below.


When a Text string block reaches a certain number of characters the text is only partially displayed. You see three dots … at the end of the visible part of the text string. The rest of the text string is still there, just not visible.


You can find the Text string block in the Text category of the Blockeditor. You can drag and drop it in the Blockeditor. When you click on the pink part of the Text string block you can type text or you can paste text that you got somewhere else.

The Text string block is one of most used blocks in a lot of projects. Here are some samples.

You don’t have to understand what every block means. It is just to show you how Text string blocks can be used.

When a Text string block is filled with a number it acts the same as a number block with the same value. Number blocks will be discussed in a different Beginners guide.


A space in a Textstring block also takes up space. :grin:

Below you can see different Text string blocks with spaces inside of them.

The first and second Text string blocks look the same. The first one is empty and the second contains 1 space character.

The other Text string blocks contain respectively 2,3,4 and 5 spaces.


This a Join block


With it you can join other text, variables, calculation results, etc, etc and display it for instance in a label.

Some samples of the use of the Join block you can see here.

By default you get a Join block with two sockets. If you want more you can use the white gear symbol in the little blue square on the top left of the Join block.

Peek 2020-06-05 10-24

You can use the white gear symbol to add but also to remove sockets.

So you could end up with a Join block looking like this. But this Join block just displays the Text string block that is behind it and nothing further.


This is the Length block


It returns the number of characters in the blok that is attached to it.

When you also use the Join block you can see that it adds all values of the attached Text string blocks together. Number blocks are treated the same way as Text string blocks.

This is the is Empty block


It will detect if the attached blocks are empty.

Some samples how you can use it.

The first result is false since the Text string block contains characters.

The second result is true since the Text string block is empty.

The third result is false since the Text string block contains a space character.

This is the is string block


With this block you can test if the block that is connected to it contains a string. For example.

As you can see you have to add a block, for instance a Text string block or variable that contains a Text string block with letters and/or numbers. If you use a Number block with the same content as a Text string block, the Number block will give a false in return and the Text string block true.

This is the compare texts block


The dropdown menu shows 4 options


> means greater then
< means smaller then
= means equal to
means not equal to

From the docs:

A string a considered lexicographically greater than another if it is alphabetically greater than the other string. Essentially, it would come after it in the dictionary. All uppercase letters are considered smaller or to occur before lowercase letters. cat would be > Cat.

To show this in examples.

CAT < cat is true because UPPERCASE goes before lowercase.
CAT ≠ cat is true because CAT is not equal to cat.
CAT = cat is false because CAT is not equal to cat.
CAT > cat is false because CAT is smaller than cat.

This is the trim block


It removes all spaces from the beginning and end of a string. The below Text string block contains a string with 5 spaces in the front and 5 spaces at the end.


When you add the trim block and execute it.


You get the following result.


You can see all spaces are removed.

this is the make UPPERCASE or lowercase block


It has two options.


It works like this. You connect a string and it converts it to either UPPERCASE or lowercase.


This is the start at text block.


It shows on what position in the string the text start that you are looking for.

Several examples:

The “B” is found at position 2. The “b” is not in the text so it gets the index 0.

The last example show the combination of the start at text block and the upcase block.

The piece string can contain more then one character.


This is the contains text block


It gives a true or false if the piece of text you want to find is or is not in the text you are searching.

Several examples.

The piece string can contain more then one character.

This is the split text block


Using the dropdown menu you can see it has 4 different options.



If you pass the block a string you can tell it where to split it. In the first case it splits the text at every occurence of the character “,”. In the second case it splits the string at the occurence of every letter “b”.

You can see what the result is. I will now use a block from the Lists category.

The split blocks generates a list in this case ( a b c)
When you want to pick the first item of that list you use the blue list block as shown.

You can split a word and put it in a list by putting an empty text string block.


The empty-string is something that has to do with the way Kodular is made and is related to java as far as i know. This has the following result when you want to call items in the list you generated.

When you select item 1 you get your empty string. When you select item 2 you get the first item of the string you split.


split at first


This blocks splits a string at the first occurence of a certain character. In the example the character “,” is used.


The textstring is split at the first “,”. So you get a list with one item “a”, and a second item “b,c”. The character that is used to split the string is omitted from the result.

split at any


With this block you can split a string with a number of different strings. In previous split blocks you were always limited to one split string. Now you can use multiple. The split strings are put in a make list block.

In the example below the string is split with the use of the character “,” and “|”.
You can see the result.


split at first of any


With this block you split a string in two at the first occurrence of one of the provided split strings that are in the make list block.


In the sample above you can see that the ", " character is the first one to be found so it is split.

You get a list that has two items. The first one is “a”, the second one “b,c,|d|e|f”.
The character that is used to split the string is omitted from the result.

This is the split at spaces block


It lets you split a textstring where the items are divided by spaces. The items are placed in a list.


The same thing can be done with these blocks. The Text string lock connected at the make a list block contains a space character.


This is the segment text block


When this block you can get a segment of a string. You have to set a starting point and how long the segment should be.


If the length number exceeds the length of the string that is tested you will get an error message. At least you get one in the companion.

This is the replace all text block


With this block you can replace a part of a string. Segment is the part to be replaced. Replacement is the part that will be used.


This is the obfuscated text block


From the documentation:

Produces text, like a text block. The difference is that th etext is not easily discoverable by examining the app’s contents. Use this when creating apps to distribute that include confidential information, for example, API keys.

Warning: This provides only very low security against expert adversaries.

This is the reverse block


This block reverses the string you attach to it.


This is the replace all mappings block.

This is a bit hard to explain. You have to use dictionary blocks with it.

With it you can replace text in a string using dictionary blocks.

You have two options when you click the dropdown menu.


Dictionary order

From the documentation:

If the dictionary order is specified, in the case of one key entry being a substring of another key entry, the first one to be replaced is based on the entry order in the dictionary (the earliest one gets replaced first).

In short: replace by element order in dictionary

Longest string first order

If the longest string order is specified, in the case of one key entry being a substring of another key entry, the first one to be replaced is the one which is longer.

In short: replace longest first, then replace the shorter substrings in order of string length


Nice Guide for Beginners.


Good and beautiful tutorial. I hope this is just the beginning. :ok_hand: :golfing_man:


Added some more blocks. Wanting to do this for a long time. Happy that I started and it is fun to do. :crazy_face:


Peter’s guide is better than docs for beginners :sunglasses:


Yes, absolutely right!

In docs only information about respective block is given, instead of that it will be better if there should be full information about how to use that block with different ways, as @Peter explained.


All textblocks are in the Beginner’s guide. Tell me what you think? Are there errors that i should fix?


great guide, which additionally shows how important it is to use the Do it feature,
see also tip 4 here App Inventor: How to Learn | Pura Vida Apps
see also Live Development, Testing, and Debugging Tools



One correction here, should be two :slight_smile:
Also, 40 edits! :scream:

1 Like

Maybe it was an error on my side. OP of last post didn’t do anything wrong.

It is certainly being one of the best tutorials! Congratulations !

1 Like

Really nice post @Peter, it was so detailed and informative. In the end I was looking is there anything else because the whole topic was so interesting.

Thanks for your efforts.

1 Like

Really today I learned a lot about this guide.

Thank you.


Using replace mapping preferring dictionary order, if some of the text doesn’t exist in dictionary, what would it returns?

Maybe you can test that and show the result here. :wink:


Definitely! Will do it when available :slightly_smiling_face:

1 Like

How to remove a segment from a text starts from word :one" … to word “three” in a text like this:
“one two three four five six”
To get
“four five six”

You can use devices utilities parse method.

Text = Your text
Starts = " three "
ends = “”
if not found = (Any string)

It might works. If not, you can join some special characters after the text and type the characters to the “ends” parameter.

Second method using replace text.
replace text = you text
segment = "one two three "
replacement = “”


You could use the split text at block image. Plug in three. It will result in a list.

Then use image with index 2 to get

1 Like

How do I get just a certain amount of letters?

Example: I have a list with 5 names, each name contains 15 letters, then I just want you to show 6 letters and then the three points.

How is it:
Real Estate

How I wanted it to look:
Casa “Imob …”