GitHub - electron/asar: Simple extensive tar-like archive format with indexing · GitHub
https://github.com/electron/asar • 342 KB fetched
Open original page
GitHub - electron/asar: Simple extensive tar-like archive format with indexing · GitHub
Skip to content
Navigation Menu
Sign in Appearance settings
* Platform
* AI CODE CREATION
* GitHub Copilot Write better code with AI
* GitHub Copilot app Direct agents from issue to merge
* MCP Registry Integrate external tools
* DEVELOPER WORKFLOWS
* Actions Automate any workflow
* Codespaces Instant dev environments
* Issues Plan and track work
* Code Review Manage code changes
* Code Quality Enforce quality at merge
* APPLICATION SECURITY
* GitHub Advanced Security Find and fix vulnerabilities
* Code security Secure your code as you build
* Secret protection Stop leaks before they start
* EXPLORE
* Why GitHub
* Documentation
* Blog
* Changelog
* Marketplace
View all features
* Solutions
* BY COMPANY SIZE
* Enterprises
* Small and medium teams
* Startups
* Nonprofits
* BY USE CASE
* App Modernization
* DevSecOps
* DevOps
* CI/CD
* View all use cases
* BY INDUSTRY
* Healthcare
* Financial services
* Manufacturing
* Government
* View all industries
View all solutions
* Resources
* EXPLORE BY TOPIC
* AI
* Software Development
* DevOps
* Security
* View all topics
* EXPLORE BY TYPE
* Customer stories
* Events & webinars
* Ebooks & reports
* Business insights
* GitHub Skills
* SUPPORT & SERVICES
* Documentation
* Customer support
* Community forum
* Trust center
* Partners
View all resources
* Open Source
* COMMUNITY
* GitHub Sponsors Fund open source developers
* PROGRAMS
* Security Lab
* Maintainer Community
* GitHub Stars
* Archive Program
* REPOSITORIES
* Topics
* Trending
* Collections
* Enterprise
* ENTERPRISE SOLUTIONS
* Enterprise platform AI-powered developer platform
* AVAILABLE ADD-ONS
* GitHub Advanced Security Enterprise-grade security features
* Copilot for Business Enterprise-grade AI features
* Premium Support Enterprise-grade 24/7 support
* Pricing
Search /
Sign in
Sign up Appearance settings
You signed in with another tab or window. Reload to refresh your session.
You signed out in another tab or window. Reload to refresh your session.
You switched accounts on another tab or window. Reload to refresh your session.
Dismiss alert
Uh oh!
There was an error while loading. Please reload this page .
electron
/
asar
Public
*
Notifications
You must be signed in to change notification settings
*
Fork
265
*
Star
2.9k
*
Code
*
Issues
6
*
Pull requests
6
*
Actions
*
Security and quality
0
*
Insights
Additional navigation options
*
Code
*
Issues
*
Pull requests
*
Actions
*
Security and quality
*
Insights
main
Branches Tags
Go to file
Code Open more actions menu
Latest commit
History
474 Commits
474 Commits
Folders and files
Name Name Last commit message
Last commit date
.github
.github
.husky
.husky
.yarn/ releases
.yarn/ releases
benchmark
benchmark
bin
bin
src
src
test
test
.gitattributes
.gitattributes
.gitignore
.gitignore
.mocharc.js
.mocharc.js
.nvmrc
.nvmrc
.oxfmtrc.json
.oxfmtrc.json
.oxlintrc.json
.oxlintrc.json
.releaserc.json
.releaserc.json
.yarnrc.yml
.yarnrc.yml
CHANGELOG.md
CHANGELOG.md
LICENSE.md
LICENSE.md
README.md
README.md
package.json
package.json
tsconfig.json
tsconfig.json
vitest.config.ts
vitest.config.ts
yarn.lock
yarn.lock
View all files
Repository files navigation
*
* README
* Code of conduct
* MIT license
More items
@electron/asar - Electron Archive
ASAR is a simple extensive archive format. It concatenates all files together without compression
(like tar ) while having random access support.
Features
* Support random access
* Use JSON to store file information
* Very easy to write a parser
* Store the contents of duplicated files only once
CLI
Install
This module requires Node 22.12.0 or later.
npm install --engine-strict @electron/asar
Usage
$ asar --help
Usage: asar [options] [command]
Commands:
pack | p < dir > < output >
create asar archive
list | l < archive >
list files of asar archive
extract-file | ef < archive > < filename >
extract one file from archive
extract | e < archive > < dest >
extract archive
Options:
-h, --help output usage information
-V, --version output the version number
Excluding multiple resources from being packed
Given:
app
(a) ├── x1
(b) ├── x2
(c) ├── y3
(d) │ ├── x1
(e) │ └── z1
(f) │ └── x2
(g) └── z4
(h) └── w1
Exclude: a, b
asar pack app app.asar --unpack-dir " {x1,x2} "
Exclude: a, b, d, f
asar pack app app.asar --unpack-dir " **/{x1,x2} "
Exclude: a, b, d, f, h
asar pack app app.asar --unpack-dir " {**/x1,**/x2,z4/w1} "
Programmatic usage
For full API usage, see the API documentation .
Example
import { createPackage } from '@electron/asar' ;
const src = 'some/path/' ;
const dest = 'name.asar' ;
await createPackage ( src , dest ) ;
console . log ( 'done.' ) ;
Please note that there is currently no error handling provided!
Deduplication
Files with identical contents are stored once and shared: the first copy is
written into the archive and every other copy's header entry points at that same
offset . Nothing changes for readers — each file still has its own entry, size,
integrity hash, and executable bit — but archives with duplicated contents (a
common shape for bundled node_modules ) get smaller and pack faster, since the
redundant bytes are never written.
Unpacked files ( unpack / unpackDir ) are always written out in full, because
they live on disk outside the archive.
Transform
You can pass in a transform option, that is a function, which either returns
nothing, or a stream.Transform . The latter will be used on files that will be
in the .asar file to transform them (e.g. compress).
import { createPackageWithOptions } from '@electron/asar' ;
const src = 'some/path/' ;
const dest = 'name.asar' ;
function transform ( filename ) {
return new CustomTransformStream ( )
}
await createPackageWithOptions ( src , dest , { transform : transform } ) ;
console . log ( 'done.' ) ;
Format
Asar uses Pickle to safely serialize binary value to file.
The format of asar is very flat:
| UInt32: header_size | String: header | Bytes: file1 | ... | Bytes: file42 |
The header_size and header are serialized with Pickle class, and
header_size 's Pickle object is 8 bytes.
The header is a JSON string, and the header_size is the size of header 's
Pickle object.
Structure of header is something like this:
{
"files" : {
"tmp" : {
"files" : {}
},
"usr" : {
"files" : {
"bin" : {
"files" : {
"ls" : {
"offset" : " 0 " ,
"size" : 100 ,
"executable" : true ,
"integrity" : {
"algorithm" : " SHA256 " ,
"hash" : " ... " ,
"blockSize" : 1024 ,
"blocks" : [ " ... " , " ... " ]
}
},
"cd" : {
"offset" : " 100 " ,
"size" : 100 ,
"executable" : true ,
"integrity" : {
"algorithm" : " SHA256 " ,
"hash" : " ... " ,
"blockSize" : 1024 ,
"blocks" : [ " ... " , " ... " ]
}
}
}
}
}
},
"etc" : {
"files" : {
"hosts" : {
"offset" : " 200 " ,
"size" : 32 ,
"integrity" : {
"algorithm" : " SHA256 " ,
"hash" : " ... " ,
"blockSize" : 1024 ,
"blocks" : [ " ... " , " ... " ]
}
}
}
}
}
}
offset and size records the information to read the file from archive, the
offset starts from 0 so you have to manually add the size of header_size and
header to the offset to get the real offset of the file.
Files with identical contents share a single copy in the archive, so more than
one entry can point at the same offset .
offset is a UINT64 number represented in string, because there is no way to
precisely represent UINT64 in JavaScript Number . size is a JavaScript
Number that is no larger than Number.MAX_SAFE_INTEGER , which has a value of
9007199254740991 and is about 8PB in size. We didn't store size in UINT64
because file size in Node.js is represented as Number and it is not safe to
convert Number to UINT64.
integrity is an object consisting of a few keys:
* A hashing algorithm , currently only SHA256 is supported.
* A hex encoded hash value representing the hash of the entire file.
* An array of hex encoded hashes for the blocks of the file (i.e. for a blockSize of 4KB, this array contains the hash of every block if you split the file into N 4KB blocks).
* A integer value blockSize representing the size in bytes of each block in the blocks hashes above.
About
Simple extensive tar-like archive format with indexing
Topics
asar chrome electron javascript pickle
Resources
Readme
MIT license
Code of conduct
Code of conduct
Activity
Custom properties
Stars
2.9k stars
Watchers
64 watching
Forks
265 forks
Report repository
Releases
Packages
Used by
Contributors
Languages
Footer
(c) 2026 GitHub, Inc.
Footer navigation
*
Terms
*
Privacy
*
Security
*
Status
*
Community
*
Docs
*
Contact
*
Manage cookies
*
Do not share my personal information
You can’t perform that action at this time.
Links found on this page
- Skip to content [direct]
- Sign in [direct]
- GitHub Copilot Write better code with AI [direct]
- GitHub Copilot app Direct agents from issue to merge [direct]
- MCP Registry Integrate external tools [direct]
- Actions Automate any workflow [direct]
- Codespaces Instant dev environments [direct]
- Issues Plan and track work [direct]
- Code Review Manage code changes [direct]
- Code Quality Enforce quality at merge [direct]
- GitHub Advanced Security Find and fix vulnerabilities [direct]
- Code security Secure your code as you build [direct]
- Secret protection Stop leaks before they start [direct]
- Why GitHub [direct]
- Documentation [direct]
- Blog [direct]
- Changelog [direct]
- Marketplace [direct]
- View all features [direct]
- Enterprises [direct]
- Small and medium teams [direct]
- Startups [direct]
- Nonprofits [direct]
- App Modernization [direct]
- DevSecOps [direct]
- DevOps [direct]
- CI/CD [direct]
- View all use cases [direct]
- Healthcare [direct]
- Financial services [direct]
- Manufacturing [direct]
- Government [direct]
- View all industries [direct]
- View all solutions [direct]
- AI [direct]
- Software Development [direct]
- DevOps [direct]
- Security [direct]
- View all topics [direct]
- Customer stories [direct]
- Events & webinars [direct]
- Ebooks & reports [direct]
- Business insights [direct]
- GitHub Skills [direct]
- Customer support [direct]
- Community forum [direct]
- Trust center [direct]
- Partners [direct]
- View all resources [direct]
- GitHub Sponsors Fund open source developers [direct]
- Security Lab [direct]
- Maintainer Community [direct]
- GitHub Stars [direct]
- Archive Program [direct]
- Topics [direct]
- Trending [direct]
- Collections [direct]
- Copilot for Business Enterprise-grade AI features [direct]
- Premium Support Enterprise-grade 24/7 support [direct]
- Pricing [direct]
- Sign up [direct]
- electron [direct]
- Notifications [direct]
- Issues
6 [direct]
- Pull requests
6 [direct]
- Actions [direct]
- Security and quality
0 [direct]
- Insights [direct]
- Branches [direct]
- Tags [direct]
- 474 Commits [direct]
- .github [direct]
- .husky [direct]
- .yarn/ releases [direct]
- benchmark [direct]
- bin [direct]
- src [direct]
- test [direct]
- .gitattributes [direct]
- .gitignore [direct]