A series of simple logic gates based on a water-soluble porphyrin molecule, 5,10,15,20-tetrakis-(4-sulfonatophenyl)porphyrin (TPPS4) is designed. Logic operations, including OR, NOR, INHIBIT and AND, have been built by two inputs of acid/base or metal ions (Al3+ and/or Sn4+) and two outputs of UV-vis absorption and fluorescent spectra. An OFF–ON switch triggered by Al3+ ion in vitro is developed based on TPPS4.