While safe chemical storage and disposal are simple in principle—users should read safety specifications and place chemicals in appropriate cabinets or collection points—high-profile incidents involving improper storage and disposal of chemicals continue to occur. This paper introduces ChemStor, an open-source, automated computational system that can guarantee (mathematically verify a system is correct with respect to its specification), with regard to prescribed constraints, safe storage and disposal of chemicals used in academic, industrial, and domestic settings. ChemStor borrows concepts from formal methods—a branch of computer science capable of mathematically proving a specification or software is correct—to safely store or dispose of chemicals. If two or more chemicals can be combined in the same cabinet without forming possibly dangerous combinations of chemicals (while observing cabinet/shelf space constraints), then ChemStor determines that the storage configuration is safe. Likewise, if chemicals can be added to an existing disposal container without forming possibly dangerous combinations of chemicals (or exceeding the volume of the container), then ChemStor determines that the disposal configuration is safe. ChemStor accomplishes this by first building a chemical interaction graph, a graph that describes which chemicals may interact with each other based on their reactivity groups as determined by the United States Environmental Protection Agency. Next, ChemStor computes the chromatic number of the graph, the smallest number of colors used to color the graph such that no two vertices (chemicals) that share an edge (an interaction) share the same color. ChemStor then assigns all the chemicals of each color to a storage or disposal container after confirming that there is enough space in the container. These steps are encoded into a series of satisfiability modulo theory equations, and ChemStor uses an industry-standard tool to try to find a valid solution to these equations. The result is either a solution which dictates exactly where to store or dispose of each chemical, or an indication that no safe storage or disposal configuration could be found. To demonstrate the feasibility of ChemStor, we used the tool to analyze ten real-world chemical storage and disposal incidents that led to injuries or destruction of property. In each case, ChemStor quickly and successfully identified a proper chemical disposal or storage configuration that would have prevented the incident. In the future, ChemStor may be integrated with electronic laboratory notebooks, voice assistants, and other emerging technology to protect users of chemicals in labs, workplaces, and homes.