Numerous living organisms possess biophotonic nanostructures that provide colouration and other diverse functions for survival. While such structures have been actively studied and replicated in the laboratory, it remains unclear whether they can be used for biomedical applications. Here, we show a transparent photonic nanostructure inspired by the longtail glasswing butterfly (Chorinea faunus) and demonstrate its use in intraocular pressure (IOP) sensors in vivo. We exploit the phase separation between two immiscible polymers (poly(methyl methacrylate) and polystyrene) to form nanostructured features on top of a Si3_N_4 substrate. The membrane thus formed shows good angle-independent white-light transmission, strong hydrophilicity and anti-biofouling properties, which prevent adhesion of proteins, bacteria and eukaryotic cells. We then developed a microscale implantable IOP sensor using our photonic membrane as an optomechanical sensing element. Finally, we performed in vivo testing on New Zealand white rabbits, which showed that our device reduces the mean IOP measurement variation compared with conventional rebound tonometry without signs of inflammation