In positioning systems in wireless sensor networks, the accuracy of localization is often affected by signal distortion or attenuation caused by environmental factors, especially in indoor environments. Although using a combination of K-Nearest Neighbor (KNN) algorithm and fingerprinting matching can reduce positioning errors due to poor signal quality, the improvement in accuracy by increasing the number of reference points and K values is not significant. This paper proposes a Differential Evolution-based KNN (DE-KNN) method to overcome the performance limitations of the KNN algorithm and enhance indoor area positioning accuracy in WSNs. The DE-KNN method aims to improve the accuracy and stability of indoor positioning in wireless sensor networks. According to the simulation results, in a simple indoor environment with four reference points, when the sensors are deployed in both fixed and random arrangements, the positioning accuracy was improved by 29.09% and 30.20%, respectively, compared to using the KNN algorithm alone. In a complex indoor environment with four reference points, the positioning accuracy was increased by 32.24% and 33.72%, respectively. When the number of reference points increased to five, in a simple environment, the accuracy improvement for both fixed and random deployment was 20.70% and 26.01%, respectively. In a complex environment, the accuracy improvement was 23.88% and 27.99% for fixed and random deployment, respectively.