All academies

Simulator

Buffers Playground

A Buffer is raw memory — a fixed-size sequence of bytes outside V8's heap. Type below and watch your text become real UTF-8 bytes, then view the same memory as hex, base64, or bits.

const buf = Buffer.from("Héllo 🌍!")12 bytes8 charactersbytes ≠ characters — that's UTF-8!

The byte grid — one cell per byte of memory

ASCII characters fit in a single byte. Accented letters and emoji need 2–4 bytes; bytes belonging to the same character share a color.

0x48
72
H
0xc3
195
é
0xa9
169
·
0x6c
108
l
0x6c
108
l
0x6f
111
o
0x20
32
␣
0xf0
240
🌍
0x9f
159
·
0x8c
140
·
0x8d
141
·
0x21
33
!

Each cell shows hex (top), decimal (middle), and the character it belongs to (bottom; continuation bytes show ·). This is why buf.length counts bytes, not characters.

Buffer.alloc(n) — claiming raw memory

const buf = Buffer.alloc(16)

Buffer.alloc(n) reserves n bytes and zero-fills them for safety (its faster sibling Buffer.allocUnsafe(n) skips the zeroing and may contain old memory). Drag the slider to grow or shrink the allocation.

00
[0]
00
[1]
00
[2]
00
[3]
00
[4]
00
[5]
00
[6]
00
[7]
00
[8]
00
[9]
00
[10]
00
[11]
00
[12]
00
[13]
00
[14]
00
[15]

16 zero-filled bytes = 128bits of memory, allocated outside V8's garbage-collected heap.