HyperScript
Docs

← All of the Docs Working with values

Text

expressionsplit <text> by <separator>since 1.3.0

A list of the pieces · split "Coins:500" by ":" gives Coins, 500

set {_parts} to split {_data} by ":"
Try it
expressionjoin <list> with <separator>since 1.3.0

The elements as one text · join {_names} with ", "

send "Online: " + join server.players with ", "
Try it
expressionuppercase <text> / lowercase <text>since 1.3.0

Changed case · uppercase "hi" gives HI

set {_shout} to uppercase (first 20 characters of {_note})
Try it
expressiontrimmed <text>since 1.3.0

Without spaces at either end · trimmed " hi " gives hi

set {_name} to trimmed args
Try it
expressionreplace <a> with <b> in <text>since 1.3.0

Every <a> replaced · replace "_" with " " in "diamond_sword"

set {_pretty} to replace "_" with " " in "diamond_sword"
Try it
expressionreplace regex <pattern> with <b> in <text>since 1.7.20

Every part the regular expression fits, replaced · replace regex "\\d+" with "#" in "a12 b345" gives a# b#

on chat:
    # Hide anything that looks like an address.
    set chat message to replace regex "\\d+\\.\\d+\\.\\d+\\.\\d+" with "[hidden]" in message
Try it
conditionregex matches of <pattern> in <text>since 1.7.20

A list of every part that fits · regex matches of "\\d+" in "a12 b345" gives 12, 345

command /numbers <text>:
    trigger:
        set {_found} to regex matches of "\\d+" in args
        send "&7Numbers: &f" + join {_found} with ", "
Try it
expressionregex groups of <pattern> in <text>since 1.7.20

What the brackets of the pattern caught in the first part that fits, as a list; the whole part if the pattern has no brackets; empty if nothing fits · regex groups of "(\\w+)=(\\d+)" in "coins=250" gives coins, 250

command /setting <text>:
    trigger:
        set {_parts} to regex groups of "(\\w+)=(\\d+)" in arg.1
        if size of {_parts} is 2:
            send "&7" + item 1 of {_parts} + " is " + item 2 of {_parts}
Try it
expressionfirst <n> characters of <text>since 1.3.0

The start of the text · first 3 characters of "Hello" gives Hel

set {_shout} to uppercase (first 20 characters of {_note})
Try it
expressionlast <n> characters of <text>since 1.3.0

The end of the text · last 2 characters of "Hello" gives lo

set {_ending} to last 3 characters of player.name
Try it
expressioncharacters <a> to <b> of <text>since 1.3.0

A slice, counting from 1, both ends included · characters 2 to 4 of "Hello" gives ell

set {_middle} to characters 2 to 4 of "Hello"
Try it
expressionlength of <text>since 1.3.0

Number of characters · length of "Hello" gives 5

if length of args > 50:
    send "&cThat is too long."
Try it
expressionrounded <number>since 1.3.0

The nearest whole number · rounded 2.5 gives 3

send "TPS: " + rounded server.tps
Try it
expressionjson of <value>since 1.7.3

A list, a local table, a number or text written out as JSON, ready to send · json of ["a", 2] gives ["a",2]

set {_body.player} to player.name
set {_body.coins} to {%player%.coins} + 0
send post request to "https://example.com/hook" with body json of {_body}
Try it
expressionjson value <path> of <text>since 1.5.2

A value out of JSON text; see Web requests · json value "id" of {_response}

log json value "name" of {_json}
Try it
expressionparse <text> as numbersince 1.5.6

The text as a number; unset if it is not one. An amount written short counts: 1.5k is 1500, 2m two million, 1b a thousand million · parse "52" as number gives 52

set {_amount} to parse arg.1 as number
if {_amount} is not set:
    send "&cThat is not a number."
Try it
expressionparse <text> as integersince 1.5.6

The same, rounded down to a whole number · parse "7.9" as integer gives 7

set {_whole} to parse "7.9" as integer
Try it
expressionparse <value> as textsince 1.5.6

A number or any other value as text · parse 52 as text gives "52"

set {_label} to parse 52 as text
Try it
expressionparse <text> as timesince 1.7.47

Text such as "1h 30m", "90 seconds" or "2 days and 4 hours" as a duration; unset if it is not one. Also written as duration · parse "1h 30m" as time gives 1 hour 30 minutes

set {_long} to parse arg.1 as time
if {_long} is not set:
    send "&cSay how long, such as 1h 30m."
    stop
send "&aMuted for %{_long}%."
Try it
expressionbar of <part> out of <whole>since 1.7.50

A bar of ten characters, as much of it filled as part is of whole. Add with <n> characters, using "<character>" and colored "<filled>" and "<rest>" as wanted · bar of 3 out of 10 gives &a███&7███████

send action bar "&7XP " + bar of {%player%.xp} out of 100 to player
Try it
expressionrandom text of <n> characterssince 1.7.55

Letters and digits picked at random, without the ones that look alike (0 and O, 1 and l): for vouchers and codes · random text of 8 characters gives something like kT7mQ2xp

set {_code} to random text of 8 characters
send "&7Your voucher: &f%{_code}%"
Try it
expressionrandom code of <n> digitssince 1.7.55

Digits only · random code of 4 digits gives something like 0382

set {_pin} to random code of 4 digits
Try it
expressionnew idsince 1.7.55

An id that nothing else has, 36 characters long · new id

set {_id} to new id
Try it
expressiontry parse <text> as numbersince 1.7.20

The same as parse, for those who like it said: text that is not a number gives unset, never an error. Works with integer and text too · try parse "abc" as number is not set

command /pay <amount>:
    trigger:
        set {_amount} to try parse arg.1 as number
        if {_amount} is not set:
            send "&c%arg.1% is not a number."
            stop
        send "&aPaying %{_amount}%."
Try it
functionduration(<seconds>)since 1.5.7

Seconds as readable time · duration(125) gives 2 minutes 5 seconds

send "&7Uptime: " + duration(125)
Try it
expressioncapitalized <text>since 1.7.0

The first letter in upper case · capitalized "hello" gives Hello

send capitalized "hello there"
Try it
expressiontitle case <text>since 1.7.0

Every word capitalised; underscores become spaces · title case "diamond_sword" gives Diamond Sword

set {_nice} to title case "diamond_sword"
send "&7You found a %{_nice}%"
Try it
expressionuncoloured <text>since 1.7.0

Without colour codes · uncoloured "&aHi" gives Hi

log uncoloured "&aGreen text"
Try it
expressionword <n> of <text>since 1.7.0

One word, counting from 1 · word 2 of "one two three" gives two

set {_first} to word 1 of args
Try it
expression<text> repeated <n> timessince 1.7.0

The text over and over · "=" repeated 20 times

send "&8" + ("-" repeated 20 times)
Try it
expression<text> padded to <n>since 1.7.1

Spaces added at the end (or in front, with padded left to), for lining things up · "Name" padded to 12

for each {_name} in server.players:
    send "&f" + ({_name} padded to 16) + "&e%{%{_name}%.coins}%"
Try it
expression<text> shortened to <n>since 1.7.59

Cut to that many characters, the last of them …, if it is longer; colour codes are not counted · "Hello world" shortened to 8 gives Hello w…

command /tag <words:text>:
    trigger:
        set {_tag} to arg.1 shortened to 12
        send "&7Your tag: &f%{_tag}%"
Try it
expression<text> wrapped to <n>since 1.7.59

A list of lines no longer than that, broken between words, each going on in the colour the one before ended in. For lore and signs · {_about} wrapped to 30

command /about:
    trigger:
        set {_about} to "&7A sword that was made long ago and has never lost a fight."
        loop {_about} wrapped to 24:
            send loop-value
Try it
expression<text> centered to <n>since 1.7.44

Spaces on both sides, so that the text stands in the middle of that many characters; colour codes are not counted · "SHOP" centered to 20

set {_title} to arg.1 centered to 30
Try it
functionbetween(text, before, after)since 1.7.44

What stands between two pieces of a text; unset if either is not there · between("Hello [world]!", "[", "]") gives world

set {_inner} to between("Hello [world]!", "[", "]")
send "&7%{_inner}%"
Try it
expression<text> parsed as numbersince 1.5.9

The same as parse ... as number, written after the value; also integer, text, player, offlineplayer · arg.1 parsed as number

set {_amount} to arg.1 parsed as number
if {_amount} is not set:
    send "&cThat is not a number."
Try it
expression<text> as offlineplayersince 1.7.26

A player by name, online now or not. For somebody who has played here it is the name as the server has it; has played before says whether they have. Also written as offline player, parsed as offlineplayer and parse <text> as offlineplayer · "Progamer52" as offlineplayer

command /seen <player>:
    trigger:
        set {_who} to arg.1 as offlineplayer
        if {_who} has not played before:
            send "&c%arg.1% has never played here."
            stop
        send "&7%{_who}% was last on " + last seen of {_who} formatted as "d MMMM yyyy"
Try it
expressionnow formatted as <pattern>since 1.5.9

The date and time, written the way the pattern says · now formatted as "HH:mm" gives 18:30

send "&7It is " + now formatted as "HH:mm"
Try it
expressionurlencoded <text>since 1.4.0

Made safe to put inside a URL · urlencoded "a b&c" gives a%20b%26c

set {_response} to send get request to "https://api.mojang.com/users/profiles/minecraft/" + urlencoded arg.1
Try it
condition<text> contains <text>since 1.3.0

Whether one includes the other, ignoring case · message contains "help"

if {winners} contains player.name:
    send "You already won."
Try it
expression<text> + <text>since 1.3.0

Joined · "Level " + 5 gives Level 5

set {_greeting} to "Hello, " + player.name
Try it
Guide and examples
SyntaxResultExample
split <text> by <separator>A list of the piecessplit "Coins:500" by ":" gives Coins, 500
join <list> with <separator>The elements as one textjoin {_names} with ", "
uppercase <text> / lowercase <text>Changed caseuppercase "hi" gives HI
trimmed <text>Without spaces at either endtrimmed " hi " gives hi
replace <a> with <b> in <text>Every <a> replacedreplace "_" with " " in "diamond_sword"
replace regex <pattern> with <b> in <text>Every part the regular expression fits, replacedreplace regex "\\d+" with "#" in "a12 b345" gives a# b#
regex matches of <pattern> in <text>A list of every part that fitsregex matches of "\\d+" in "a12 b345" gives 12, 345
regex groups of <pattern> in <text>What the brackets of the pattern caught in the first part that fits, as a list; the whole part if the pattern has no brackets; empty if nothing fitsregex groups of "(\\w+)=(\\d+)" in "coins=250" gives coins, 250
first <n> characters of <text>The start of the textfirst 3 characters of "Hello" gives Hel
last <n> characters of <text>The end of the textlast 2 characters of "Hello" gives lo
characters <a> to <b> of <text>A slice, counting from 1, both ends includedcharacters 2 to 4 of "Hello" gives ell
length of <text>Number of characterslength of "Hello" gives 5
rounded <number>The nearest whole numberrounded 2.5 gives 3
json of <value>A list, a local table, a number or text written out as JSON, ready to sendjson of ["a", 2] gives ["a",2]
json value <path> of <text>A value out of JSON text; see Web requestsjson value "id" of {_response}
parse <text> as numberThe text as a number; unset if it is not one. An amount written short counts: 1.5k is 1500, 2m two million, 1b a thousand millionparse "52" as number gives 52
parse <text> as integerThe same, rounded down to a whole numberparse "7.9" as integer gives 7
parse <value> as textA number or any other value as textparse 52 as text gives "52"
parse <text> as timeText such as "1h 30m", "90 seconds" or "2 days and 4 hours" as a duration; unset if it is not one. Also written as durationparse "1h 30m" as time gives 1 hour 30 minutes
bar of <part> out of <whole>A bar of ten characters, as much of it filled as part is of whole. Add with <n> characters, using "<character>" and colored "<filled>" and "<rest>" as wantedbar of 3 out of 10 gives &a███&7███████
random text of <n> charactersLetters and digits picked at random, without the ones that look alike (0 and O, 1 and l): for vouchers and codesrandom text of 8 characters gives something like kT7mQ2xp
random code of <n> digitsDigits onlyrandom code of 4 digits gives something like 0382
new idAn id that nothing else has, 36 characters longnew id
try parse <text> as numberThe same as parse, for those who like it said: text that is not a number gives unset, never an error. Works with integer and text tootry parse "abc" as number is not set
duration(<seconds>)Seconds as readable timeduration(125) gives 2 minutes 5 seconds
capitalized <text>The first letter in upper casecapitalized "hello" gives Hello
title case <text>Every word capitalised; underscores become spacestitle case "diamond_sword" gives Diamond Sword
uncoloured <text>Without colour codesuncoloured "&aHi" gives Hi
word <n> of <text>One word, counting from 1word 2 of "one two three" gives two
<text> repeated <n> timesThe text over and over"=" repeated 20 times
<text> padded to <n>Spaces added at the end (or in front, with padded left to), for lining things up"Name" padded to 12
<text> shortened to <n>Cut to that many characters, the last of them …, if it is longer; colour codes are not counted"Hello world" shortened to 8 gives Hello w…
<text> wrapped to <n>A list of lines no longer than that, broken between words, each going on in the colour the one before ended in. For lore and signs{_about} wrapped to 30
<text> centered to <n>Spaces on both sides, so that the text stands in the middle of that many characters; colour codes are not counted"SHOP" centered to 20
between(text, before, after)What stands between two pieces of a text; unset if either is not therebetween("Hello [world]!", "[", "]") gives world
<text> parsed as numberThe same as parse ... as number, written after the value; also integer, text, player, offlineplayerarg.1 parsed as number
<text> as offlineplayerA player by name, online now or not. For somebody who has played here it is the name as the server has it; has played before says whether they have. Also written as offline player, parsed as offlineplayer and parse <text> as offlineplayer"Progamer52" as offlineplayer
now formatted as <pattern>The date and time, written the way the pattern saysnow formatted as "HH:mm" gives 18:30
urlencoded <text>Made safe to put inside a URLurlencoded "a b&c" gives a%20b%26c
<text> contains <text>Whether one includes the other, ignoring casemessage contains "help"
<text> + <text>Joined"Level " + 5 gives Level 5
command /banner <text>:
    trigger:
        set {_title} to arg.1 centered to 30
        send "&8[&f%{_title}%&8]"
        for each {_word} in words of "red green blue":
            send "&7%{_word}%"
        set {_inner} to between("Hello [world]!", "[", "]")
        set {_bar} to lerp(0, 20, 0.25)
        send "&7%{_inner}% %{_bar}%"
set {_data} to "Coins:500"
set {_parts} to split {_data} by ":"
set {_coins} to item 2 of {_parts} + 100
send "You have %{_coins}% coins"
  • parse is how text that came from a player, a file or a web page becomes a number you can rely on. If the text is not a number the result is unset, which is easy to test for:
set {_amount} to parse arg.1 as number
if {_amount} is not set:
    send "&c'%arg.1%' is not a number."
    stop
  • Directly after send, the word title means a title on screen, so put title case in a variable first or in brackets: send (title case {_item}).
  • Any colour: besides &a style codes, text may use <#rrggbb> for an exact colour, as in "<#ff8800>Orange <#00c8ff>and blue". It works wherever colour codes do, on Minecraft 1.16 and newer.
  • now formatted as takes Java's date letters: yyyy year, MM month number, MMMM month name, d day, EEEE weekday name, HH hour, mm minute, ss second. "d MMMM yyyy 'at' HH:mm" gives 11 October 2026 at 18:30. Text inside single quotes is taken as it is.
  • The separator in split is taken literally, and splitting by "" gives the single characters.
  • Pieces of split text still work as numbers, as item 2 of {_parts} + 100 shows.
  • Slices that run past either end of the text are cut to fit; they never cause an error.
  • Each of these takes the single value right after it. To apply one to a longer expression, use parentheses: uppercase (first 3 characters of {_name}).
  • A new line in text is written %nl%, or %new line%: send "&6Rules%nl%&71. Be kind". It works in every text: chat, holograms, lore, files, and text in front of a player.