Home › Developer Tools › Logic Gate Simulator

Logic Gate Simulator

Design digital logic circuits right in your browser. Drag gates, switches, LEDs, a clock and flip-flops onto the board, connect pins with wires and flip the switches to watch signals propagate. The truth table and a simplified Boolean expression update as you build.

Last updated:

Truth table

Advertisement
Advertisement

How to use the Logic Gate Simulator

  1. Drag parts onto the board from the toolbar (or click a part to drop it in a free spot). Start with Switches for inputs and LEDs for outputs.
  2. Wire the circuit: press on an output pin (right side of a part) and drag to an input pin (left side). Drag a wire off an input to move or remove it.
  3. Flip the switches by clicking them; wires and pins turn green when they carry a 1, and LEDs light up.
  4. Read the truth table below the board: it lists every input combination and the simplified Boolean expression for each LED.
  5. For sequential circuits, add a Clock and flip-flops, then press Start clock or Step clock. Download the truth table or save the circuit when you are done.

Logic gates reference

GateOutput is 1 when…ExpressionA=0,B=00,11,01,1
ANDall inputs are 1A·B0001
ORat least one input is 1A + B0111
XORan odd number of inputs are 1A ⊕ B0110
NANDnot all inputs are 1(A·B)'1110
NORall inputs are 0(A + B)'1000
XNORan even number of inputs are 1(A ⊕ B)'1001
NOTthe single input is 0A'A=0 → 1, A=1 → 0

NAND and NOR are called universal gates: any circuit can be built from either one alone. The XOR from 4 NAND gates example shows how.

Flip-flop characteristic tables

TypeInputs at the rising clock edgeNext Q
D flip-flopD = 0 / D = 10 / 1 (Q follows D)
T flip-flopT = 0 / T = 1Q (hold) / Q' (toggle)
JK flip-flopJ=0,K=0 · J=0,K=1 · J=1,K=0 · J=1,K=1hold · 0 · 1 · toggle
SR latch (no clock)S=1,R=0 · S=0,R=1 · S=0,R=0 · S=1,R=11 · 0 · hold · invalid (Q = Q̅ = 0)

Classic circuits to try

  • Half adder: adds two bits. Sum S = A ⊕ B, carry C = A·B. 1 + 1 gives S = 0, C = 1, which is binary 10.
  • Full adder: adds two bits plus a carry-in, the building block of every binary adder. Chain full adders to add multi-bit numbers, and check the results with the Binary Calculator.
  • 2-to-1 multiplexer: Y = A·S' + B·S, so the select switch S chooses which input reaches the output.
  • 2-bit counter: two T flip-flops on the same clock. Q0 toggles every cycle and Q1 toggles when Q0 is 1, so Q1Q0 counts 00, 01, 10, 11. Watch it with Start clock.

To see how gate operations act on whole binary numbers at once, try the Bitwise Calculator (AND, OR, XOR and NOT on integers).

Frequently asked questions

How do I connect two gates?

Press on the small circle on the right side of a part (its output) and drag to the circle on the left side of another part (an input), then release. The wire snaps to the nearest input within a short distance. An input accepts only one wire; connecting a new one replaces the old one. To remove a wire, click it and press Delete, or drag it off the input pin and release on empty board.

What do the colors mean?

A green wire, pin or gate fill carries a logic 1 (high); grey means 0 (low). Switches show 1 or 0, and an LED glows when its input is 1. Unconnected inputs are treated as 0.

How is the truth table made?

The simulator sets the switches to every combination from all 0s to all 1s (2^n rows for n switches), lets the circuit settle, and records each LED. Columns follow the parts' positions on the board from top to bottom, so place switch A above switch B to get the usual order. The row matching the current switch positions is highlighted.

How is the Boolean expression simplified?

Each output's minterms (the rows where it is 1) are reduced with the Quine–McCluskey method, which merges terms that differ in one variable, and then a set of prime implicants covering every minterm is chosen. The result is a correct sum of products that is minimal or close to minimal; A' means NOT A, a dot means AND and + means OR.

How do the flip-flops behave?

The D, JK and T flip-flops are positive-edge triggered: they change only when their CLK input goes from 0 to 1. D copies its input; JK sets with J, resets with K and toggles when both are 1; T toggles when T is 1. The SR latch is level-sensitive: S=1 sets Q, R=1 resets it, and S=R=1 is the invalid state where both outputs are 0.

Why does it say the circuit oscillates?

A feedback loop with an odd number of inverters, such as a NOT gate whose output feeds its own input, never settles to a stable value. The simulator stops after a fixed number of passes and shows a warning. Loops with an even number of inversions, like the cross-coupled NOR latch, are stable and work as memory.

Is my circuit saved?

Yes, the current circuit is stored in this browser's local storage and reopens when you return. Use Download circuit to keep a .json file you can open later or share; nothing is uploaded.

Are all the tools on FreeToolCabin tested for quality and accuracy?

Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.

Related tools

Binary CalculatorAdd, subtract, multiply, divide, AND, OR, XOR and shift binary numbers with decimal values.Bitwise CalculatorCalculate AND, OR, XOR, NOT and bit shifts at 8–64 bits with a bit grid and all bases.Binary to DecimalConvert binary to decimal instantly with steps and signed mode.Binary TranslatorConvert text to binary, hex, octal and back.Brain TeasersLogic, lateral-thinking and math brain teasers with hints and full solutions, including a kids level.Conway's Game of LifeDraw cells and watch them evolve: play, step, change speed, load gliders and guns, import RLE.Logic Grid PuzzlesSolve Einstein-style deduction puzzles with clues and an ✗/✓ grid, from easy to hard.Online Python CompilerRun Python 3 in your browser with input(), numpy, pandas, charts and share links.JSON EditorEdit JSON in a tree and as code side by side: add, rename, drag, change types, undo and download.Unzip FilesOpen and extract ZIP files online.RAR & 7z ExtractorOpen RAR, 7z and other archives online and extract files.Regex TesterTest and debug regular expressions live.File Info ViewerCheck file size, type, date and MD5/SHA hashes.SQLite ViewerOpen .db and .sqlite files in your browser, browse tables and run SQL queries.DOCX ViewerOpen and read Word .docx files in your browser, then print or save them as HTML.EPUB ReaderOpen and read EPUB e-books in your browser with pages, a table of contents and font controls.What Is My BrowserSee your browser, version, OS, engine, screen and which web features it supports.Font ViewerPreview TTF, OTF, WOFF and WOFF2 fonts with sample text, waterfall, glyphs and metadata.Markdown EditorWrite Markdown with a toolbar, live split preview, autosave and .md or HTML export.Regex Cheat Sheet75+ ready-to-use regex patterns for emails, URLs, IPs and dates, each with a live test box.JavaScript Keycode FinderPress any key to see its JavaScript key, code, keyCode, which, location and modifiers.QR Code ScannerScan QR codes with your camera or from an image and safely read the link or text.RAID CalculatorUsable capacity, efficiency and fault tolerance for RAID 0, 1, 5, 6, 10, 50 and 60 arrays.JSONPath TesterTest JSONPath expressions live: filters, slices, wildcards and recursive search, with matches highlighted.Mermaid Diagram EditorWrite Mermaid code and see flowcharts, sequence, Gantt and ER diagrams live. Export SVG or PNG.Country Codes ListSearch ISO 3166 alpha-2, alpha-3 and numeric country codes with calling codes and TLDs.CSS Selector TesterTest CSS selectors on your HTML: highlighted matches, match count and specificity.Git Cheat SheetSearchable Git command reference by task, with copy buttons and an undo/rename/fix wizard.HAR File ViewerOpen a .har file to see a waterfall timeline, headers, bodies, timings and size totals.jq PlaygroundRun jq filters on JSON in your browser with live output, flags and an example library.Markdown Cheat SheetInteractive Markdown syntax reference: edit every example and see the live rendered preview.Regex ExplainerPaste a regular expression and get a plain-English breakdown, railroad diagram and flag notes.XPath TesterTest XPath expressions on XML or HTML: highlighted matches, node paths, values and examples.EML File ViewerOpen .eml email files to read the message, headers and raw source and save attachments.Graphviz Online ViewerWrite Graphviz DOT code and render graphs live; switch layout engines, export SVG or PNG.JavaScript Online CompilerWrite and run JavaScript in your browser with a console, timing, error lines and share links.Jupyter Notebook ViewerOpen .ipynb files and read code, Markdown, math, tables, plots and errors without Python.LaTeX Table GeneratorEdit a table like a spreadsheet or paste from Excel and get LaTeX tabular or booktabs code.Semantic Version CalculatorBump, compare, sort and test SemVer versions against npm ^, ~ and x ranges.XSLT TesterRun an XSLT 1.0 stylesheet on XML in your browser and see the output as HTML, XML or text.ASCII Diagram EditorDraw boxes, arrows and text on a character grid and copy plain-text diagrams for code and READMEs.DBF File ViewerOpen dBase .dbf files and shapefile tables, search and sort records, export CSV or XLSX.MBOX File ViewerOpen .mbox mail archives: list and search messages, read them, save attachments, export EML.MDB File ViewerOpen Access .mdb and .accdb databases in your browser: list tables, view rows, export CSV.Shapefile ViewerView zipped shapefiles on a map with the attribute table, then export to GeoJSON or CSV.Log File ViewerOpen huge log files with level colors, regex and time filters, JSON pretty-print and tail -f.MSG File ViewerOpen Outlook .msg emails in your browser: sender, recipients, body, headers and attachments.Online Code EditorVS Code-style editor in your browser: tabs, 50+ languages, find/replace, autosave.Online Hex EditorOpen any file as hex and ASCII, edit bytes, search, inspect values and save the result.PHP Online CompilerRun PHP 8 code in your browser with output, HTML preview, error lines and share links.PlantUML EditorWrite PlantUML and see sequence, class, activity and more diagrams live. Export SVG or PNG.Sorting Algorithm VisualizerWatch bubble, insertion, merge, quick, heap and radix sort step by step with live counters.Lottie ViewerOpen Lottie JSON or .lottie files to play, pause, scrub frames, change speed and see details.Diff ViewerPaste a git diff or .patch file and view it side by side or inline, with file navigation.EditorConfig GeneratorBuild an .editorconfig with indent, charset, line endings and trim rules per file pattern.Folder Compare ToolCompare two folders by file list, size and SHA-256 hash, then open a text diff of changed files.Glob Pattern TesterTest glob patterns like **/*.js, {a,b} and !exclusions against a list of file paths.JMESPath TesterEvaluate JMESPath expressions against JSON live, the query language used by the AWS CLI.MongoDB Query TesterTest MongoDB find filters, projections and aggregation pipelines on sample JSON documents.
See all 53 Code Playgrounds & Testers →