Detect if DevTools is open
See the codenpm install devtools-detector --save
import { addListener, launch } from 'devtools-detector';
const view = document.createElement('div');
document.body.appendChild(view);
// 1. Add listener
addListener((isOpen) => {
view.innerText = isOpen ? 'DevTools status: open' : 'DevTools status: closed';
});
// 2. Launch detection
launch();
require(['devtools-detector'], function (devtoolsDetector) {
const view = document.createElement('div');
document.body.appendChild(view);
devtoolsDetector.addListener(function (isOpen) {
view.innerText = isOpen
? 'DevTools status: open'
: 'DevTools status: closed';
});
devtoolsDetector.launch();
});
<script src="node_modules/devtools-detector/lib/devtools-detector.js"></script>
<script>
const view = document.createElement('div');
document.body.appendChild(view);
devtoolsDetector.addListener(function (isOpen) {
view.innerText = isOpen
? 'DevTools status: open'
: 'DevTools status: closed';
});
devtoolsDetector.launch();
</script>
interface DevtoolsDetail {
isOpen: boolean;
checkerName: string;
}
type DevtoolsDetectorListener = (
isOpen: boolean,
detail?: DevtoolsDetail
) => void;
launch(): Start detection
isLaunch(): Returns true if detection is active, false otherwise
stop(): Stop detection
addListener(listener: DevtoolsDetectorListener): Add a listener
removeListener(listener: DevtoolsDetectorListener): Remove a listener
setDetectDelay(value: number): Set detection loop delay time. If value <= 0, detection stops.
crashBrowserCurrentTab(): Crash the current browser tab (tested only on Chrome)
// Example: crash the current browser tab 2 seconds after DevTools is opened
import { addListener, crashBrowserCurrentTab } from 'devtools-detector';
addListener(function (isOpen) {
if (isOpen) {
setTimeout(crashBrowserCurrentTab, 2000);
}
});
crashBrowser(): Crash all browser tabs (tested only on Chrome)
devtools-detector is loaded before other scripts.MIT © AEPKILL
Overall
Maintained
Code review
Latest release
Releases this year
129 followers · starred Jun 2024
6 followers · starred Jul 2025
84 followers · starred Dec 2020
89 followers · starred Feb 2023
Detect if DevTools is open
See the codenpm install devtools-detector --save
import { addListener, launch } from 'devtools-detector';
const view = document.createElement('div');
document.body.appendChild(view);
// 1. Add listener
addListener((isOpen) => {
view.innerText = isOpen ? 'DevTools status: open' : 'DevTools status: closed';
});
// 2. Launch detection
launch();
require(['devtools-detector'], function (devtoolsDetector) {
const view = document.createElement('div');
document.body.appendChild(view);
devtoolsDetector.addListener(function (isOpen) {
view.innerText = isOpen
? 'DevTools status: open'
: 'DevTools status: closed';
});
devtoolsDetector.launch();
});
<script src="node_modules/devtools-detector/lib/devtools-detector.js"></script>
<script>
const view = document.createElement('div');
document.body.appendChild(view);
devtoolsDetector.addListener(function (isOpen) {
view.innerText = isOpen
? 'DevTools status: open'
: 'DevTools status: closed';
});
devtoolsDetector.launch();
</script>
interface DevtoolsDetail {
isOpen: boolean;
checkerName: string;
}
type DevtoolsDetectorListener = (
isOpen: boolean,
detail?: DevtoolsDetail
) => void;
launch(): Start detection
isLaunch(): Returns true if detection is active, false otherwise
stop(): Stop detection
addListener(listener: DevtoolsDetectorListener): Add a listener
removeListener(listener: DevtoolsDetectorListener): Remove a listener
setDetectDelay(value: number): Set detection loop delay time. If value <= 0, detection stops.
crashBrowserCurrentTab(): Crash the current browser tab (tested only on Chrome)
// Example: crash the current browser tab 2 seconds after DevTools is opened
import { addListener, crashBrowserCurrentTab } from 'devtools-detector';
addListener(function (isOpen) {
if (isOpen) {
setTimeout(crashBrowserCurrentTab, 2000);
}
});
crashBrowser(): Crash all browser tabs (tested only on Chrome)
devtools-detector is loaded before other scripts.MIT © AEPKILL
Overall
Maintained
Code review
Latest release
Releases this year
129 followers · starred Jun 2024
6 followers · starred Jul 2025
84 followers · starred Dec 2020
89 followers · starred Feb 2023