A way to prevent developer tools

Is there a way to prevent dev tools from being opened?
Edit to clarify: I’m asking about how to do this in an app that uses the electron framework.

1 Like

Are you asking about Atom, the text editor, or Electron, the application framework,? Adding a category to your topic would help clarify.

1 Like

I didn’t notice that this board covered so much other than electron. I’ve edited the OP to clarify.


1 Like

Still haven’t found a solution to this.

To elaborate in case I wasn’t clear enough, currently in my electron app you can open devtools by pressing Ctrl + Shift + I. I’d like to remove this capability.

There doesn’t seem to be a reliable way to tell if devtools is open via javascript.

Here you go.

1 Like

Thanks @DamnedScholar

The final solution:
win.webContents.on("devtools-opened", () => { win.webContents.closeDevTools(); });

1 Like

If you want to prevent users from opening DevTools via the keyboard shortcut just don’t add a DevTools menu item


Except ctrl+shift+i will still open them. See discord for example, no dev tools menu there but you can still open it.

1 Like

The solution:

mainWindow = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
devTools: false


Thank you, this is indeed the solution.

A hacker who wants to break into your code can still just replace the devtools: false with devtools:true

An improved solution detects whether your browser has been resized. Even if the hacker doesn’t resize the app’s window, it will still trigger a window.onResize event if the devtools console opens because the app’s window is the entire window minus the devtools space. In an onResize event you should close devtools using win.webContents.closeDevTools().

            let electron = require("electron");

Even this solution can be hacked, but it’s better than nothing. Slack, which is an Electron app seems to have come up with a proprietary solution that I personally have not been able to crack.

hi guys ,whatever you do they can disable the code (comment the code or write a code to active the devtools)
is there any idea to create a c/c++ addons to disable the devtool even the user wirte a code to active the devtools

Can it be disabled

well this is it i tried it and it worked

thank u so much