Upconversion nanoparticles (UCNPs), as near-infrared (NIR) absorbers, are promising materials for use in flexible NIR photodetectors, which can be applied for wearable healthcare applications due to their advantages in a broad spectral range, high photostability, and biocompatibility. However, to apply UCNPs in wearable and large-area integrated devices, water stability and micro-patterning methods are required. In this work, the UCNPs are encapsulated with a siloxane polymer (UCNP@SiOx) via a sol-gel process to enable photo-patternability and photo-stabililty in water conditions. The UCNP@SiOx can be photo-patterned down to micron-scale feature sizes and exhibit no significant decrease in upconversion photoluminescence (PL) intensities and PL decay time after immersion in water for 2 h. Moreover, UCNP@SiOx is evaluated by an in vitro biocompatibility test and found to be non-toxic. By integrating the UCNP@SiOx with MoS2 phototransistors (MoS2 + UCNP@SiOx), the devices exhibit enhanced responsivity (0.79 A W-1) and specific detectivity (2.22 x 10(7) Jones), which are 2.8 times higher than in the bare MoS2 phototransistors, and excellent mechanical durability over 1000 cycles of 20% compression and re-stretch test. This work opens the way for the facile synthesis of water-stable and photo-patternable siloxane-encapsulated UCNPs and a strategy for fabricating high-performance flexible NIR phototransistors through wavelength conversion.