Decoding tools

Use our DCS decoder to quickly and easily decode your Didomi Consent Strings and view their contents in a human-readable format.

SDK API - Web

The Didomi Web SDK provides a JavaScript API to decode the Didomi Consent String (DCS). This API can be used in two ways depending on your needs:

Simple decoding

This method allows you to decode a DCS string into a readable JSON object containing the user’s consent preferences, timestamps, and vendor/purpose consents.

Use this if you’re only interested in accessing and inspecting user consent choices (e.g. for debugging or integration validation).

Query example

const factory = Didomi.getCedFactory()
undefined
dcs = "dcs_token_with signature".split('.')[0]
'dcs_token_without_signature'
factory.decode(dcs)

Response example

{
  "user_id": "19710e89-951e-6842-8355-d094b60e4924",
  "created": "2025-05-27T08:42:48.500Z",
  "updated": "2025-05-27T08:42:51.000Z",
  "purposes_optin": {
    "enabled": [
      3,
      5,
      8,
      9,
      10,
      16,
      80
    ],
    "disabled": []
  },
  "purposes_optout": {
    "enabled": [],
    "disabled": []
  },
  "vendors_optin": {
    "enabled": [
      2,
      3,
      1010
    ],
    "disabled": []
  },
  "vendors_optout": {
    "enabled": [
      2
    ],
    "disabled": []
  }
}

Granular decoding

This advanced method provides insight into the internal structure of the DCS, including the encoding strategy used for each field and its offset in the binary string. This is useful for debugging, validation, or developing your own decoder.

Query example

const entries = [];
undefined
const logs = { enabled: true, entries };

undefined
factory.decode(dcs, {logs})
{user_id: '19710e89-951e-6842-8355-d094b60e4924', created: '2025-05-27T08:42:48.500Z', updated: '2025-05-27T08:42:51.000Z', purposes_optin: {…}, purposes_optout: {…}, …}
entries

Response example

[
    {
        "key": "version",
        "offset": 0,
        "usedEncoder": "u6"
    },
    {
        "key": "user_id",
        "offset": 6,
        "usedEncoder": "UUID"
    },
    {
        "key": "created",
        "offset": 134,
        "usedEncoder": "date"
    },
    {
        "key": "updated",
        "offset": 170,
        "usedEncoder": "date"
    },
    {
        "key": "sync",
        "offset": 206
    },
    {
        "key": "purposes_optin",
        "offset": 207,
        "usedEncoder": "bitField2Bits"
    },
    {
        "key": "purposes_optout",
        "offset": 386,
        "usedEncoder": "bitField2Bits"
    },
    {
        "key": "vendors_optin",
        "offset": 405,
        "usedEncoder": "rangesFibonacci"
    },
    {
        "key": "vendors_optout",
        "offset": 451,
        "usedEncoder": "bitField2Bits"
    }
]

Coming soon - Open source DCS library

We’re currently working on open-sourcing the DCS library, which will allow you to encode and decode the Didomi Consent String with greater flexibility. This will be particularly useful if you’re building advanced tools, integrations, or custom debugging utilities.

Last updated