A novel three-dimensional porous chitosan membrane material was prepared as a matrix to encapsulate hepatitis B surface antibody (HBsAb) for fabrication of immunosensors. The porous chitosan matrix was prepared by electrodepositing a designer nanocomposite solution of chitosan-encapsulated silica nanoparticle hybrid film on an ITO electrode, and then removing the silica nanoparticles with HF solution. Using HBsAb as a model, the potentiometric immunosensor was constructed by linking HBsAb molecules to the three-dimensional porous chitosan film using glutaraldehyde as a cross-linker. Scanning electron microscopy was used to investigate the surface morphology of the three-dimensional porous chitosan films. Cyclic voltammograms and electrochemical impedance spectroscopy were used to probe the interfacial properties of the immunosensor. Results showed that the fabricated immunosensor with three-dimensional porous structure possessed high surface area, good mechanical stability, and good hydrophilicity, which provided a biocompatible microenvironment for maintaining the bioactivity of the immobilized protein and increased the protein loading. Therefore, the present immunosensor exhibits a wide linear range from 6.85 to 708 ng mL(-1) with a low detection limit of 3.89 ng mL(-1) for the detection of hepatitis B surface antigen (HBsAg). This work implied that the biocompatible and controllable three-dimensional porous chitosan membrane possessed potential applications for biosensing.