Skip to content

Make a HUD ​

A 5Stack HUD file is a .zip with a hud.json and one XML layout per variant. The game streamer draws it on the GPU the same way it draws the built-in 5Stack HUD, which is written in this format too. Import it under Settings → Application → Broadcast HUDs; see Broadcast HUDs.

A small HUD ​

hud.json:

json
{
  "format": "5stack-hud",
  "formatVersion": 1,
  "name": "Minimal",
  "font": "Oxanium",
  "text": { "size": 18, "weight": 600, "color": "#f0f6fc" },
  "colors": {
    "panel": "#0c0f14db",
    "CT": "#4794eb",
    "T": "#f99e2f",
    "red": "#ff6452"
  },
  "hide": ["sponsor"],
  "variants": { "main": "main.xml" }
}

main.xml:

xml
<hud>
  <style name="pn" bg="$panel" radius="8" clip="true"/>

  <def name="card" params="p">
    <col key="p.steamid" w="152" class="pn" pad="8" gap="6" opacity="{{ 1 if p.alive else 0.5 }}" transition="280ms">
      <text ellipsis="true">{{ p.name }}</text>
      <bar h="6" radius="3" bg="#ffffff1f" value="p.health" max="100" fill="${{ p.side }}" animate="280ms smooth"/>
      <row justify="between" size="15">
        <text color="#8fdca4">{{ p.money|money }}</text>
        <text>{{ p.kills }}/{{ p.deaths }}</text>
      </row>
    </col>
  </def>

  <piece name="scoreboard" flow="row" x="760" y="18" w="400" h="56" class="pn" align="center" justify="between" pad-x="16">
    <text color="${{ left.side }}">{{ left.name }}</text>
    <text size="28">{{ left.score }} : {{ right.score }}</text>
    <text color="${{ right.side }}">{{ right.name }}</text>
  </piece>

  <piece name="players_left" flow="row" x="24" bottom="24" gap="6">
    <each in="left.players" as="p" key="p.steamid"><use def="card" p="{{ p }}"/></each>
  </piece>
  <piece name="players_right" flow="row" right="24" bottom="24" gap="6" reverse="true">
    <each in="right.players" as="p" key="p.steamid"><use def="card" p="{{ p }}"/></each>
  </piece>

  <piece name="bomb" if="bomb.planted" x="810" y="90" w="300" class="pn" pad="12" gap="8"
    enter="fold 240ms fold" exit="fold 200ms ease-in">
    <row gap="8" align="center"><icon name="c4" h="20" color="$red"/><text>{{ t('bomb_planted') }}</text></row>
    <bar h="6" fill="$red" max="1" value="bomb.left" animate="100ms linear"/>
  </piece>
</hud>

This HUD draws the scoreboard, the player cards and the bomb timer. It leaves out the radar, the round history, the series and the other pieces, so the streamer draws its own in their place, and it hides the sponsor, so nobody draws that.

The zip ​

my-hud.zip
├── hud.json
├── shared.xml        styles and defs every variant reads
├── horizontal.xml    one layout per variant
├── icons/flag.svg    your own icons
├── img/logo.png      your own pictures
└── fonts/MyFont.ttf  your own fonts

Only hud.json and the layouts are needed. The files can also sit inside one top-level folder. Leave index.html out: a zip with hud.json and no index.html is checked as a HUD file whatever hud.json says, so a mistake in it is shown. Files and folders whose name starts with a dot are left out and don't count, and so are __MACOSX/, Thumbs.db and desktop.ini.

File names are UTF-8, also in a zip made on a Mac. A name in decomposed letters (é as an e and an accent) is another name than the composed one. The import says so for the files hud.json names.

Limit
Zip32 MB
Unpacked96 MB
Files300
The HUD's name100 letters
Nodes written in the layouts2,000 per variant
Nodes once every use and each is worked out4,000 per frame
Nesting64 deep as written, 200 once every use is worked out, a use inside a use 16 deep
Variants8
Attributes on a node128
shared files16
hud.json and the layouts together1 MB
One expression1,000 characters written, 10,000 characters of result
Work per frame50,000 steps (nodes looked at, each rounds and expressions)

Links (symlinks), absolute paths, paths with .. and paths with \ are refused. An expression that takes too long to work out is stopped.

hud.json ​

Key
formatRequired, "5stack-hud".
formatVersionRequired, 1.
nameRequired.
variantsRequired. Name to layout file, such as { "horizontal": "horizontal.xml" }. The first is the default. A name is 1 to 64 letters, digits, _, . or -, and not . or ...
canvas{ "width": 1920, "height": 1080 }, the size the layouts are written for. 1 to 8192 each, 1920 × 1080 if left out.
fontThe font family text uses unless a node says otherwise.
fontsFont files in the zip (.ttf or .otf) to load. Oxanium, DejaVu Sans Mono and Noto Sans (with its Arabic, Japanese, Korean and Chinese cuts) are always there.
textWhat text looks like where nothing says otherwise: size and weight (1 to 1000), line (times the size), color. Without it text is 16 px, weight 400, white.
colorsNamed colors, such as { "panel": "#0c0f14db" }. A layout uses them as $panel, or $panel/50 at half its opacity.
sharedFiles every variant reads first. They hold only <style> and <def>.
hidePieces nobody draws, not this HUD and not the streamer.

Any other key is a problem, except $schema.

Layouts ​

A layout is a <hud> that holds <style>, <def> and <piece> elements. Comments (<!-- -->) are fine. Text outside a <text> is a problem, since it would not be drawn.

Nodes ​

NodeWhat it isIts own attributes
pieceA part of the HUD, placed on the canvas. Goes right inside <hud>. Its children stack in a column, or in a row with flow="row". Without a position it sits at the top left.name, flow
rowChildren side by side.
col, boxChildren one under the other.
eachIts children once for every item of a list.in and as (required), index, sort, limit
useA def's nodes.def (required) and the def's params
textText, with {{ }} in it.roll
imgA picture.src (required), fit, pos, grayscale, fallback, crop
iconAn SVG icon in the text color.name (required)
barA meter.value (required), max, fill, fill-to, dir, segments, seg-gap, animate, ghost, ghost-time
radarThe radar, with players, grenades and the bomb.dot, ct, t, watched, ink, bomb, defused, smoke, fire, grid, smooth, labels, label-weight, blast
cameraA place the camera of the player being watched shows through.

Every node can also have:

  • if: an expression; the node and everything in it are drawn only when it is true.
  • key: an expression that keeps a node the same node from one frame to the next, so a player card keeps its place in its animation when the list around it changes. Use key="p.steamid" on anything repeated by each.
  • class: styles to apply, by name (not on each or use).
  • piece: the node belongs to that piece. It hides with the piece, and the HUD counts as drawing it, so a piece can live inside another one (not on each or use).
  • The style attributes below (not on each or use).

each ​

  • in is a list, such as left.players, or a number to repeat that many times (up to 1,000).
  • as names the item, index names its number, from 0.
  • sort="kills" sorts by a field of the items, sort="-kills" the other way.
  • limit keeps the first so many.

img ​

  • src is a file in the zip (img/logo.png), a data: URI, or a picture from the data, such as left.logo or p.photo. PNG, JPEG, WebP, GIF and SVG work. The import doesn't check it: where a picture is missing, the node's fallback is drawn, or nothing if it has none.
  • fit: contain (the default), cover or stretch. pos: left, right, top, bottom or center, such as pos="bottom".
  • grayscale: true or false.
  • fallback: text drawn when there is no picture, such as {{ left.name|initials }}.
  • crop: the part of the picture to show, as left top width height fractions, such as 0.2 0 0.6 0.5.

icon ​

name is icons/<name>.svg from the zip if it is there, else one of the streamer's weapon and equipment icons, named as CS2 names them: ak47, awp, m4a1_silencer, deagle, hegrenade, flashbang, smokegrenade, molotov, c4, planted_c4, defuser, armor_helmet, taser, knife and the rest. A player's weapons carry their icon name, as in p.best.icon. An icon is drawn in the node's color; a name with no icon draws a plain gun shape.

bar ​

  • value and max (100 unless given) are expressions; the bar fills value / max.
  • fill is a color, fill-to a second color for a gradient. dir: right (the default), left, up or down.
  • segments splits it into that many blocks, seg-gap pixels apart (2 unless given).
  • animate moves it to a new value over a time. ghost leaves a trail in that color when the value drops, which catches up over ghost-time (600ms 250ms out unless given).

radar ​

The radar reads radar from the data by itself. dot is the player dot size (20 unless given). ct, t, watched, ink, bomb, defused, smoke, fire and grid are colors. smooth moves the dots over a time. Each dot carries the player's observer key in the ink color; labels="false" leaves the keys off, and label-weight is their font weight. blast is how a bomb going off shows: wave (the default) runs it down the map's corridors, lines adds the 2D player's blast radius to the wave, and none shows neither. On a map with no radar image, only the dots are drawn.

Styles and classes ​

xml
<style name="card" bg="$panel" pad="8 10" radius="8"/>
<style name="dead" opacity="0.42"/>

<row class="card {{ 'dead' if not p.alive }}" pad-l="3">…</row>

A <style> takes any of the style attributes. A node's class applies them in order, and its own attributes win over them. Text attributes (color, font, size, weight, line, upper, tabular, spacing, text-align, ellipsis) are handed down to the nodes inside, as in CSS.

Style attributes ​

GroupAttributes
Placex, y, right, bottom: any of them takes the node out of the flow, to that place in its parent. w, h, min-w, max-w, min-h, max-h.
Flowgrow, shrink, basis, flex (grow from nothing), gap, align and self (start, center, end, stretch, baseline), justify (start, center, end, between, around), reverse, clip.
Spacepad, pad-x, pad-y, pad-t, pad-r, pad-b, pad-l, and the same for margin. pad and margin take one to four values, as CSS does.
Lookbg, with bg-to and bg-angle (0 points up, 90 right) for a gradient. border, border-t, border-r, border-b, border-l, border-color and border-t-color and so on. radius (one to four corners). shadow (x y blur spread color). opacity, scale. hatch, hatch-width, hatch-gap for diagonal stripes.
Textcolor, font, size, weight, line (times the size, or 24px), upper, tabular, spacing (pixels between letters), text-align (left, center, right), ellipsis.
Motionenter, exit, transition, move, resize. See Motion.
  • Lengths are pixels (24 or 24px), percent of the parent (50%) or auto.
  • Colors are #rgb, #rgba, #rrggbb, #rrggbbaa, rgb(r,g,b), rgba(r,g,b,a), white, black, transparent, or one from hud.json as $name or $name/50.
  • True and false are true, yes, 1 and false, no, 0, none.

Motion ​

A time is written 280ms, 280ms settle (with an ease), or 600ms 250ms smooth (start 250 ms later). The eases are linear, out, in, in-out, ease, ease-in, ease-out, settle, smooth, fold and pop, or your own as bezier(x1,y1,x2,y2).

  • enter and exit: how a node comes and goes: fade, slide-up, slide-down, slide-left, slide-right, fold or pop, then a time. A slide can say how far (slide-up 40 180ms settle, 24 px unless given), a pop what size it starts from (pop 1.4 240ms pop, 0.6 unless given). They all fade too; fold 240ms fold, fade 180ms 140ms ease gives the fade its own time.
  • transition: opacity, fill, border, text color and scale change over this long.
  • move: a node that moves to a new place in its parent gets there over this long.
  • resize: a size or place set in pixels changes over this long.
  • roll on a text rolls the digits that change, as an odometer does (roll="700ms settle", or roll="true").
  • pulse loops for as long as a node is shown: pulse="700ms 0.5 1.12" takes its opacity to 0.5 and its size to 1.12 and back every 700 ms. The HUD draws every frame while anything pulses, so keep it for what must catch the eye.

Defs ​

A <def> is a part you write once and use many times. params names what it takes; <use> has to give all of them.

xml
<def name="logo" params="src, name, size">
  <img if="src" w="{{ size }}" h="{{ size }}" src="{{ src }}"/>
  <col if="not src" w="{{ size }}" h="{{ size }}" radius="6" bg="#ffffff24" align="center" justify="center">
    <text size="{{ (size * 0.4)|round }}" weight="700">{{ name[:1] }}</text>
  </col>
</def>

<use def="logo" src="{{ left.logo }}" name="{{ left.name }}" size="{{ 30 }}"/>
  • An attribute that is a lone {{ }} passes its value as it is: a player, a list, a number, {{ true }}. Anything else passes text, so write size="{{ 30 }}", not size="30".
  • Inside a def, the names are its params and the data; the as names of an each around the use are not there, so pass them as params.

Expressions ​

{{ }} goes in text and in any attribute. Expressions are Jinja expressions: names and fields (left.score, colors[p.side]), numbers and text, + - * /, ~ to join text (* multiplies numbers only, so 'x' * 3 is refused), comparisons, and, or, not, x if y else z, and slices such as name[:2]. There are no statements or loops; each and if do that.

if, key, each's in and limit, and bar's value, max, segments and seg-gap, and radar's dot and label-weight are expressions already, so if="p.alive" and if="{{ p.alive }}" are the same.

The filters are these, and only these:

FilterExampleGives
money{{ 12850|money }}$12,850
clock{{ 64.2|clock }}1:05
pad{{ 7|pad }}, {{ 7|pad(3) }}07, 007
upper{{ left.name|upper }}NIGHT SHIFT
round{{ 12.6|round }}, {{ 12.25|round(1) }}13, 12.2
initials{{ left.name|initials }}NS

Besides the data, an expression can read colors (the colors of hud.json, as #rrggbbaa text), variant (the variant being drawn), and t().

A name the data doesn't have is a problem when the HUD is imported, with the closest name it could have meant. On air, a field that is empty reads as nothing, and a value that turns out wrong, such as a color that isn't one, is skipped for that frame.

Text ​

Inside a <text>, runs of spaces and line breaks become one space, as in HTML. Control characters in names become spaces, and a text stops at 500 characters.

Translations ​

t('key'), t('key', {'count': 3}) and t('key', {}, 'shown instead') give the streamer's own words in the HUD language set under Settings → Application → Broadcast HUDs, in any of the 18 languages the web app has, with English for anything missing. {name} in a message takes {'name': …}, and a message written one | many picks its form by count. A key with no message draws the third argument. The import refuses a key no language has, unless it has a third argument. It can't check a key that is worked out, such as t('round_' ~ n): on air, one with no message and no third argument draws nothing. Text you write yourself is drawn as you wrote it.

The keys
KeyEnglish
round_ofRound {n} of
ot_roundOT {ot}, round
map_ofMap {n} of
finalFinal
pausePause
timeouts_left{count} timeout left | {count} timeouts left
best_ofBest of
map_nMap
series_tiedSeries tied {a}–
series_leads{team} leads {a}–
series_wins{team} wins the series {a}–
picked_byPicked by
decider_mapDecider map
liveLive
finishedFinished
deciderDecider
presented_byPresented by
timeoutTimeout
left{count} left
technical_pauseTechnical pause
match_pausedMatch paused
halftimeHalftime
teams_switchTeams switch sides
warmupWarmup
starts_soonMatch starts soon
planting{player} is planting
bomb_plantedBomb planted
defusing{player} is defusing
defusing_kit{player} is defusing with a kit
in_timeIn time
too_lateToo late
wins_round{team} wins the round
team_eliminatedTeam eliminated
bomb_detonatedBomb detonated
bomb_defusedBomb defused
time_ran_outTime ran out
round_mvpRound MVP
defused_bombDefused the bomb
planted_bombPlanted the bomb
kills{count} kill | {count} kills
damage{count} damage
damage_titleDamage
kills_titleKills
full_buyFull buy
force_buyForce buy
ecoEco
equipmentEquipment
loss_bonusLoss bonus
team_moneyTeam money
maps_wonMaps won
round_historyRound history
k, d, a, adrK, D, A, ADR
tournament.round_labels.roundRound
tournament.round_labels.wb_roundWB Round
tournament.round_labels.lb_roundLB Round
tournament.round_labels.opening_roundOpening Round
tournament.round_labels.wb_opening_roundWB Opening Round
tournament.round_labels.quarter_finalsQuarter Finals
tournament.round_labels.wb_quarter_finalsWB Quarter Finals
tournament.round_labels.semi_finalsSemi Finals
tournament.round_labels.wb_semi_finalsWB Semi Finals
tournament.round_labels.finalFinal
tournament.round_labels.wb_finalWB Final
tournament.round_labels.grand_finalGrand Final
tournament.round_labels.lb_finalLB Final

A tournament stage has no words of its own to write: draw it in the HUD's language, with the English name where the language has none, with

xml
<text if="match.stage_key or match.stage">{{ t(match.stage_key, match.stage_params, match.stage) }}</text>

Pieces ​

A piece is a part of the HUD the streamer knows by name. A layout draws a piece with <piece name="…">, or with piece="…" on any node. A <piece> with no name is only a group, placed on the canvas.

PieceWhat it is
scoreboardThe teams, the score and the round clock
players_left, players_rightThe player cards of each team
observedThe player being watched
cameraThe camera of the player being watched
radarThe radar
bombThe plant and defuse timer
roundsThe round history
seriesThe maps of the series
timeoutTimeouts, pauses, halftime and warmup
round_endWho won the round, and how
freezetimeMoney and buys during freezetime
match_endThe end of a map
clutchA player alone against several
sponsorThe sponsor's pictures
mvpThe round's MVP

A piece a variant doesn't draw is drawn by the streamer, in the first free spot. A piece named under hide in hud.json is drawn by nobody. A streamer can still hide the whole HUD from the Control Room.

The data ​

These are the names a HUD can read. The left and right teams are the teams on each side of the HUD; they stay put when the teams change sides, unless the operator presses Swap sides.

NameFields
readyCS2 has sent its first update.
swappedThe operator swapped the sides.
matchThe series: id, event, stage (of the tournament, in English), stage_key and stage_params (the same for t()), best_of, wins_needed, number (of the map being played), map_count, leader (left, right or empty), leader_name, leader_wins, other_wins, decided, maps
match.mapsname, label, number, state (finished, live, upcoming), current, decider, picked_by, picked_by_name, picked_by_logo, winner, winner_name, left_score, right_score
mapname, label, mode, phase (warmup, live, intermission, gameover), overtime
roundnumber, max, phase (freezetime, live, over), since (seconds in that phase; about 1000 when the HUD did not see the phase begin), live, freezetime, over, pistol, last_of_half, frozen (nobody can move), halftime
clocktext, seconds, phase, low (ten seconds or less), paused, shown
left, right, ct_team, t_teamA team
observedThe player being watched, or nothing
bombstate (carried, dropped, planting, planted, defusing, defused, exploded), player, player_name, planted, planting, defusing, defused, exploded, dropped, seconds, timer_known, total, left (0 to 1), low, action_seconds, action_total, action_done (0 to 1), kit, in_time
roundsOne per round of regulation, or of the overtime being played: number, played, current, new_half, winner (left or right), side (CT or T), reason (elimination, bomb, defuse or time)
timeoutactive, team, side, name, seconds, text, remaining
pauseactive: a technical pause
round_endactive, winner, side, name, reason, star (the round's MVP, a player), star_why (defused, planted, kills or damage)
match_endactive (from 3 seconds after the last round, so its last kill is seen), winner, side, name, series_over, left_wins, right_wins, draw
clutchactive, team, player, player_name, versus, star
radarWhat <radar> draws: map, image, players, grenades, bomb, and blasting while a bomb's blast plays
cameraon, steamid
sponsoron, image (the one shown now), images

team ​

at (left or right), side (CT or T), is_ct, is_t, name, short_name, initials, logo, score, series_wins, series (one true or false per map needed), timeouts, losses, loss_bonus, money, equip_value, buy (full, force or eco), buy_label, utility (smokes, flashes, hes, fires, decoys, total, percent), alive, health, won_round, match_point, map_point, players.

player ​

steamid, name, country, avatar, photo, photo_kind (roster, a cut-out that stands on the bottom edge; avatar, a square; or none), camera (their camera's picture, when it is on), initials, at, side, is_ct, is_t, key (the observer key), observed, alive, health, low, armor, helmet, kit, bomb, c4_health (the health a planted bomb would leave them if it went off now), flashed, smoked, burning, money, equip_value, round_kills, round_headshots, round_damage, kills, assists, deaths, kd, adr, mvps, score, weapon (in hand), primary, secondary, best (the primary, else the pistol), grenades, taser.

A weapon has name, label, icon, slot (primary, secondary, knife, grenade, bomb or other), active, reloading, reload (how far the reload is, 0 to 100), seated (the new magazine is in), silent (a reload slow enough to make no sound), lost (the rounds thrown away with the old magazine), has_ammo, clip, clip_max, reserve, low and count (grenades of a kind are one entry).

Checking a HUD ​

The import checks the whole HUD before it is saved, and lists every problem with its file, line and column, such as:

main.xml:12:9 unknown-name `p` has no `helth`, did you mean `health`?

On a machine with the game streamer, 5stack-hud validate my-hud.zip (or a folder) prints the same as JSON, {ok, kind, variants, pieces, errors: [{file, line, col, code, message}]}, and exits with 1 when there is a problem. The limit on the HUD's name is the import's alone: validate doesn't know it, and the import says so in one sentence, without a file or line.

CodeMeaning
bad-zip, too-large, too-many-files, symlink, bad-pathThe zip can't be read or breaks a limit.
bad-nameA file's name isn't UTF-8, or the zip has two names for it.
missing-fileA file named in hud.json isn't in the zip.
bad-iconAn icon with a picture (<image>) or an entity (<!ENTITY>) in it.
bad-json, not-a-hud, wrong-version, unknown-key, missing-name, missing-variants, bad-variant-name, bad-canvas, bad-colorSomething in hud.json.
bad-xml, bad-rootA layout isn't XML, or doesn't start with <hud>.
unknown-element, misplaced, stray-textA node that doesn't exist, or is in the wrong place.
unknown-attribute, missing-attribute, bad-valueAn attribute a node doesn't take, needs, or can't read.
bad-expression, unknown-name, unknown-filterAn expression that can't be read, or reads a name or filter that doesn't exist.
unknown-messageA t() key that no language has, with no third argument.
unknown-class, unknown-def, unknown-piece, duplicateA style, def or piece that doesn't exist, or two with the same name.
too-many-variantsMore than 8 variants.
too-many-attributesA node with more than 128 attributes.
internalThe HUD could not be checked. The import says no more than that.
too-many-nodes, too-deepA layout over the node limits.