Float32 Embedding and Base64 Converter – Free

Turn a JSON array of numbers into a Float32 embedding in Base64, or decode a Base64 embedding back into a readable array. The conversion uses little-endian IEEE 754 single precision and runs in your browser.

How to use the Float32 Embedding ↔ Base64 tool

  1. Under Operation, choose Encode numeric array to produce Base64, or Decode Base64 to get numbers back.
  2. Paste the JSON array or the Base64 string into Numeric JSON array or Base64. Select Example to try [0.25, -0.5, 1.0].
  3. Select Convert to run the chosen operation.
  4. Copy the Base64 string or the JSON array from the Result box.

How a Float32 embedding becomes Base64

An embedding is a list of floating-point numbers. As JSON text each value takes a dozen characters or more. As binary, IEEE 754 single precision stores each value in exactly 4 bytes: 1 sign bit, 8 exponent bits and 23 fraction bits. The encoder writes every number as such a 4-byte value in little-endian order, least significant byte first, and then Base64-encodes the whole buffer.

The size is easy to predict. A vector with 1,536 dimensions is 6,144 bytes and always 8,192 Base64 characters, while the same vector as decimal text is usually two to four times larger. That is why embedding APIs offer a base64 encoding format next to plain float arrays, and why caches and vector pipelines often keep embeddings in this form.

Worked example: three values

The Example values are exact in binary, so they are easy to follow. 0.25 is 0x3E800000, -0.5 is 0xBF000000 and 1.0 is 0x3F800000. Written least significant byte first they become the 12 bytes below, and 12 bytes encode to 16 Base64 characters with no padding.

Decoding AACAPgAAAL8AAIA/ returns [0.25,-0.5,1]. The output is compact JSON, and whole numbers print without a decimal point.

[0.25, -0.5, 1.0]

00 00 80 3E   00 00 00 BF   00 00 80 3F

AACAPgAAAL8AAIA/

Precision: why decoded numbers look different

Single precision keeps about 7 significant decimal digits. JavaScript and JSON numbers are doubles with about 16. When you encode 0.1, the nearest Float32 is stored, and decoding prints that stored value with full double precision: 0.10000000149011612. Nothing went wrong. This is the real value a Float32 holds.

If the embedding came from a model that computes in Float32, the round trip is lossless. If you encode doubles from another source, expect differences around the eighth digit, which is normally negligible for similarity search.

Input rules and error messages

Both directions validate strictly, so a bad vector is caught here and not later in your index.

  • Encode needs a non-empty JSON array of numbers. Strings, null, nested arrays and an empty array give Enter an array of finite Float32 values.
  • Values beyond the Float32 range, about 3.4e38 in magnitude, are rejected because they would become Infinity.
  • Text that is not valid JSON, such as numbers without brackets, shows the browser's JSON syntax error.
  • Decode accepts standard or URL-safe Base64, with or without padding, and a data URL header.
  • The decoded length must be a multiple of 4 bytes, otherwise you see Float32 arrays must contain four bytes per number.
  • Buffers containing NaN or Infinity are refused with The input contains non-finite Float32 values.

Frequently asked questions

What byte order does the Base64 embedding use?

Little-endian. Each number is 4 bytes with the least significant byte first, which is the native order on x86 and ARM machines and the layout NumPy produces for float32 arrays on those systems. Big-endian data decodes to wrong values here.

How do I decode a Base64 embedding in Python?

Decode the string with base64.b64decode and read the bytes as little-endian float32, for example with numpy.frombuffer. The array length is the byte count divided by 4.

Why do I get more digits after decoding than I entered?

The decoder prints the exact Float32 value as a double. 0.2 becomes 0.20000000298023224 because that is the closest single-precision number. Round to 7 or 8 significant digits if you want a tidy display.

How many Base64 characters does an embedding need?

Multiply the dimension count by 4 to get bytes, then by 4/3 and round up to a multiple of 4. A 768-dimension vector is 3,072 bytes and 4,096 characters. A 3,072-dimension vector is 12,288 bytes and 16,384 characters.

Are my embeddings uploaded?

No. Encoding and decoding use the binary data APIs built into your browser. The vector you paste is not transmitted or stored.

Related tools