DEV Community

CBT Tools
CBT Tools

Posted on Edited on

How I Built a Cognitive Distortion Detector in 200 Lines of Vanilla JavaScript — No ML, No NLP Library, No API

How I Built a Cognitive Distortion Detector in 200 Lines of Vanilla JavaScript

I built a free, privacy-first CBT cognitive distortion detector that runs entirely in the browser — no AI, no backend, no signup required. Here's how.

The Problem

As developers, we often fall into cognitive distortions:

  • Mind reading: 'My reviewer thinks I am a bad developer'
  • Catastrophizing: 'This bug will bring down production'
  • All-or-nothing: 'If it is not perfect, it is garbage'

The Solution

A 200-line vanilla JS detector that identifies 10 cognitive distortions using keyword matching + context scoring.

How It Works

  1. Input: User types their anxious thought
  2. Analysis: Each distortion is scored based on keyword matches + context
  3. Output: Top 3 distortions with reframing suggestions

Try It

The tool is free at cbt-toolkit. No data leaves your browser.

Why Vanilla JS?

  • Privacy: No data sent to servers
  • Speed: Instant feedback
  • Accessibility: Works offline

Continue Reading — CBT Tools for Developers:

Top comments (0)