{"id":25286667,"url":"https://github.com/jonathanlurie/serialize64","last_synced_at":"2026-04-28T11:02:40.892Z","repository":{"id":57356702,"uuid":"340314291","full_name":"jonathanlurie/serialize64","owner":"jonathanlurie","description":"Typed Arrays serialization that just works and the JSON codec that goes with it. Node and browsers.","archived":false,"fork":false,"pushed_at":"2021-03-31T22:03:23.000Z","size":1323,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-12T23:13:39.091Z","etag":null,"topics":["base64","json","serialization","typedarrays","umd"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jonathanlurie.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-02-19T09:06:32.000Z","updated_at":"2024-05-23T10:34:58.000Z","dependencies_parsed_at":"2022-08-28T19:22:29.882Z","dependency_job_id":null,"html_url":"https://github.com/jonathanlurie/serialize64","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":"jonathanlurie/es6module","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathanlurie%2Fserialize64","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathanlurie%2Fserialize64/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathanlurie%2Fserialize64/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathanlurie%2Fserialize64/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonathanlurie","download_url":"https://codeload.github.com/jonathanlurie/serialize64/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247509240,"owners_count":20950232,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["base64","json","serialization","typedarrays","umd"],"created_at":"2025-02-12T21:50:57.793Z","updated_at":"2026-04-28T11:02:35.507Z","avatar_url":"https://github.com/jonathanlurie.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\nEncodes typed arrays (*Uint8Array*, *Float32Array*, etc.) into base64 strings with a prefix that makes it decodable back into their original typed without having to store anything on the side.\n\nThere is also a JSON encoder provided.\n\n# Install and import\n```\nnpm install serialize64\n```\n\nImport from a HTML file:\n```HTML\n\u003cscript src=\"serialize64.umd.js\"\u003e\u003c/script\u003e\n```\n\nImport from ES6 module:\n```js\nimport { Codec, JSON64 } from 'serialize64'\n```\n\n# Example with simple typed arrays\nAll the examples are available in the [example folder](./examples).  \n\n```js\n// Some data\nconst someData = new Uint8Array([1, 2, 3, 4, 5, 6, 99])\n\n// encoding:\nconst someStrData = serialize64.Codec.encode(someData)\n// the value is \"_S64___ui8:AQIDBAUGYw==\"\n\n// decoding:\nconst decoded = serialize64.Codec.decode(someStrData)\n// the value is Uint8Array([1, 2, 3, 4, 5, 6, 99])\n```\n\n# Example with JSON\n```js\n// Create some data:\nconst data = {\n  aString: 'hello there',\n  aNumber: 42,\n  anArray: [0, 'one', 'deux', 'tres', 4],\n  anObject: {\n    aUint8Array: new Uint8Array([1, 2, 3, 4, 5, 6, 7]),\n    aFloat32Array: new Float32Array([1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7]),\n    anotherArray: [\n      'a string',\n      422,\n      new Int32Array([-100000, 32, 9999999])\n    ]\n  }\n}\n\n// Encoding:\nconst json64Serialized = serialize64.JSON64.stringify(data, null, 2)\n\n// Decoding:\nconst dataDecoded = serialize64.JSON64.parse(json64Serialized)\n```\n\n## Replacers and revivers\nThe *JSON64* serializer is using the regular *JSON* shipped with JS and it simply adds `Codec.encode()` and `Codec.decode()` as JSON replacers and revivers.  \nThat being said, it is still possible to add your custom replacers and revivers **in addition to** the the one from Serialize64. \n\n```js\n// Some data:\nconst data = {\n  aString: 'hello there',\n  aNumber: 42,\n  anArray: [0, 'one', 'deux', 'tres', 4],\n  anObject: {\n    aUint8Array: new Uint8Array([1, 2, 3, 4, 5, 6, 7]),\n    aFloat32Array: new Float32Array([1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7]),\n    anotherArray: [\n      'a string',\n      422,\n      new Int32Array([-100000, 32, 9999999])\n    ]\n  }\n}\n\n\nconst replacer = (key, value) =\u003e {\n  return typeof value === 'number' ? value * 2 : value\n}\n\n\nconst reviver = (key, value) =\u003e {\n  return typeof value === 'number' ? value / 2 : value\n}\n\n// Encoding:\nconst json64Serialized = serialize64.JSON64.stringify(data, replacer, 2)\n\n// Decoding:\nconst dataDecoded = serialize64.JSON64.parse(json64Serialized, reviver)\n```\n\nNote that your custom replacer is performing just before the serialize64 replacer, while your custom reviver is performing just after the serialize64 reviver. This ensures that custom replacers/reviver that would apply some change on numerical data are still doing their job as expected and the custom ones who are performing actions on strings are not messing up with the internal representation of serialize64.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonathanlurie%2Fserialize64","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonathanlurie%2Fserialize64","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonathanlurie%2Fserialize64/lists"}