Why base64 is involved at all
Subscription formats exist in two layers. The outer layer is a list of node links, one per line, each a URI with its own scheme. The inner convention, used by many providers, is to base64-encode that whole list so it travels as a single opaque blob and survives transports that mangle line breaks.
The client fetches the blob, decodes it, then parses the URIs. A decode failure happens at the middle step, which means the fetch succeeded — bytes arrived — and the content is not what the client expected.
Read the first bytes before changing anything
The fastest path to the cause is to look at what came back:
curl -sS "$URL" | head -c 200
The first characters identify the case immediately:
| First bytes | What it is | Meaning |
|---|---|---|
<!DOCTYPE or <html | An HTML page | An error page, a park page, or a login wall |
vless://, vmess://, ss://, trojan:// | Plain links | The subscription is not encoded; the client is expecting the wrong format |
{ | JSON, often a Clash profile | The URL serves a different format than the one selected |
A long run of A-Z a-z 0-9 + / = | Actual base64 | The content is encoded; the failure is inside it |
| Empty | Nothing | A different failure entirely — an empty response |
Four of those five rows are not decode problems. They are format or access problems whose first visible symptom is a decode error, and treating them as encoding issues leads nowhere.
The genuine decode failures
Truncation
Base64 is length-sensitive: the decoder works in four-character groups, and a body cut short leaves a trailing group that cannot be resolved. This produces a decode error rather than an EOF, because the bytes that did arrive were not flagged as incomplete.
Compare the declared length against the received length. A body shorter than the header claims is truncation, and the cause is on the path rather than at the provider.
Two variants of the alphabet
Base64 has a standard alphabet and a URL-safe one that replaces two characters. A decoder expecting one rejects the other at the first occurrence of the substituted character, which can be thousands of bytes into the body — so the error reports a position that seems unrelated to the problem. If the body is otherwise well formed and fails late, this is worth checking.
Line breaks and surrounding whitespace
Some servers wrap encoded output at a fixed column. A decoder that does not strip line breaks fails on the first wrap. The tell is a body with regular line lengths, which is visible in a terminal.
Padding stripped
The trailing = characters are padding, and some generators omit them. Lenient decoders accept this and strict ones do not. A body whose length is not a multiple of four but is otherwise valid points here.
Format mismatch is more common than encoding
Most reports of this error turn out to be the client being told to expect base64 when the URL serves something else. Subscription URLs often accept a format parameter, and the same token can serve links, base64, or a full Clash profile depending on it.
So check what the client is configured to expect against what the URL actually returns. If the URL serves a Clash YAML and the client is set to a link format, the mismatch is in the selection, not in the data.
This is also why the same subscription can work in one client and fail in another: the two are asking for different formats, or one is inferring the format from content and the other is not.
What not to do
- Do not re-encode the body yourself. If the content is HTML or plain links, encoding it produces a valid base64 blob of the wrong thing. The client decodes it happily and then fails to parse, moving the error later without fixing anything.
- Do not paste the body into the client manually. Some clients accept a direct paste, but a body that failed to decode will fail the same way, and you lose the ability to see the raw response.
- Do not assume expiry. An expired subscription usually still returns content, often with a notice, and rarely produces a decode failure on its own.
The useful record is the first hundred bytes, the declared and received lengths, and what format the client was configured to expect. Those three identify every case above.
Frequently asked
Does this mean my subscription expired?
Usually not. Expiry typically returns content with a notice, or a specific status. A decode failure means the bytes were not the expected encoding, which is more often an error page or a format mismatch.
The URL shows links in my browser. Why does the client fail?
Because the browser is displaying the decoded or raw body while the client expects base64. If the body is plain links, tell the client the format is links rather than encoded, or request the encoded variant from the URL.
Can a browser extension or proxy break this?
Yes. Anything that rewrites the response — an ad blocker, a translation extension, an inspecting proxy — can alter the body enough that decoding fails. Fetch with a plain command-line client to compare.
Is it safe to base64-encode the response myself to make it work?
No. If the content is not a node list, encoding it produces valid base64 of the wrong content, and the failure moves from decode to parse. Fix the source of the response instead.
Why does it fail partway through the body?
That points at an alphabet substitution or a length problem rather than at the first byte. A standard-versus-URL-safe alphabet mismatch fails at the first substituted character, which can be far into the body.