The on-line fault diagnosis of transformer based on PSO and kmeans algorithm is proposed in the paper. Firstly, the three rations data of oil chromatogram is clustered by the kmeans algorithm. Then the three rations that can represent every type of the transformer fault are optimized using PSO. When the diagnosis cannot be analyzed by the improved three-ration method caused of code deficiency, the distance between the three rations of the oil chromatographic sample that need to be analyzed and the optimal three rations of every fault type is computed. The fault type with the nearest distance is the final fault type of the sample. Secondly, combined with the multi-parameter on-line monitor data, the transformers fault is diagnosed with rule library. Finally, the feasibility and efficiency of the method proposed in the paper is demonstrated by the experiment.