241

I have packed my Electron application using the following command:

asar pack app app.asar

Now, I need to unpack it and get the whole code back. Is there any way to do so?

2 Answers 2

395

From the asar documentation

(the use of npx here is to avoid to installing the @electron/asar tool globally with npm install -g @electron/asar)

Extract the whole archive:

npx @electron/asar extract app.asar <destfolder>

Extract a particular file:

npx @electron/asar extract-file app.asar main.js
14
  • 2
    worked fine when run with sudo. Thanks for the answer, you are a life saver :) Commented Jul 22, 2016 at 11:06
  • 56
    The electron docs say: "you can also package your app into an asar archive to avoid exposing your app's source code to users." but it is not true if you are then able to unpack it? right??
    – neoDev
    Commented Dec 10, 2016 at 13:21
  • 12
    Side note: you can install the command with npm install -g asar. Commented Apr 2, 2017 at 9:16
  • 12
    Ok, how do you unpack a asar file without having to install the entire node development environment?
    – Fake Name
    Commented May 19, 2017 at 1:16
  • 41
    @FakeName - I used the 7Zip plugin found in this thread at the 7Zip project: sourceforge.net/p/sevenzip/discussion/45797/thread/74cf1dec Allows one to open any ASAR file in 7Zip.
    – MayaPosch
    Commented Dec 2, 2017 at 13:23
79

It is possible to upack without node installed using the following 7-Zip plugin:
http://www.tc4shell.com/en/7zip/asar/

Thanks @MayaPosch for mentioning that in this comment.

4
  • This does not seem to work for my use case. I have tried the plugin with both 7-Zip 21.07 (2021-12-26) and 7-Zip 19.00 (2019-02-21), as the plugin was last released in version 1.2 on 2020-03-05. Everything in 64-bit.
    – Wok
    Commented Apr 4, 2022 at 7:43
  • Also with 7-Zip 16.04 (2016-10-04). In every attempt, I get an "unspecified error".
    – Wok
    Commented Apr 4, 2022 at 7:51
  • Investigating at github.com/electron/asar/issues/110 as well.
    – Wok
    Commented Apr 4, 2022 at 7:57
  • Asar.64.dll v1.4 (28 Nov 2022, latest from tc4shell.com/en/7zip/asar) works perfectly with 7-Zip 23.01 (x64): just copy Asar.64.dll into the "7-zip\Formats" subfolder as well with the Total7zip pluging of Total Commander (just copy the same dll into totalcmd\plugins\wcx\Total7zip\64\Codecs) Commented Oct 3, 2023 at 13:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.