# encodeBase64UrlToBase64

## `encodeBase64UrlToBase64` Function

The `encodeBase64UrlToBase64` function converts a **Base64URL-encoded string** back into a **standard Base64** format. This is useful for decoding or interoperability with systems that expect standard Base64 syntax.

***

### Purpose

Use this function when you need to:

* Convert a **Base64URL-safe string** into a **valid Base64 string**
* Decode values originally encoded in Base64URL (e.g., JWT segments)
* Restore compatibility with tools or APIs that do not accept Base64URL

> 🔗 Specification: [Base64URL Standard – base64.guru](https://base64.guru/standards/base64url)

***

### Function Definition

| Property          | Description                               |
| ----------------- | ----------------------------------------- |
| **Function Name** | `this.encodeBase64UrlToBase64`            |
| **Type**          | `function`                                |
| **Available In**  | Server-Side Variables                     |
| **Returns**       | `string` (Base64-standard encoded output) |

***

### Parameters

| Parameter | Description                      | Type     | Required                                      | Example     |
| --------- | -------------------------------- | -------- | --------------------------------------------- | ----------- |
| `input`   | A valid Base64URL-encoded string | `string` | <i class="fa-square-check">:square-check:</i> | `"YWJjKys"` |

***

### Conversion Behavior

This function performs the following transformations:

| Base64URL Character | Replaced With (Base64)                      |
| ------------------- | ------------------------------------------- |
| `-`                 | `+`                                         |
| `_`                 | `/`                                         |
| *(padding)*         | Adds `=` to match Base64 length (if needed) |

***

### Example Usage

```js
async function() {
    let x = this.encodeBase64UrlToBase64("YWJjKys"); // Base64URL of "abc++"
    return x; // → "YWJjKys="
}
```

This example converts a Base64URL-safe string into a valid Base64 string by restoring special characters and padding.

***

### Use Cases

* Decode JWT payloads or headers encoded in Base64URL
* Restore encoded values for Base64-compatible APIs
* Ensure data consistency across encoding formats

***

### Notes

* The input **must** be a valid Base64URL string.
* This function **does not decode** the value — it only **reformats** Base64URL to Base64. Use decoding functions separately if needed.
* Automatically restores padding (`=`) when missing.

***

### Summary

`this.encodeBase64UrlToBase64` enables seamless transformation of Base64URL-safe strings into **standard Base64** format. It ensures compatibility with systems expecting strict Base64 syntax, making it essential for working with JWTs, APIs, or external integrations in JENTIS.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.jentis.com/developer-guide/variables/server-side-variables/public-function-scope/encodebase64urltobase64.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
