X-ray phase analysis of clays is difficult because these materials generally consist of a mixture of different phases, i.e., mixed-layer minerals, individual clay minerals (non mixed-layer), and associated minerals, such as calcite and quartz. The analysis requires knowledge that presently is incorporated in a computer-based expert system. This expert system is capable of a) identification of associated minerals; b) identification of individual clay minerals; c) identification of the nature of the mixed-layer minerals; d) approximate structural characterization of the mixed-layer minerals; and e) precise structural determination of the mixed-layer minerals by comparison of experimental X-ray diffraction (XRD) patterns with calculated patterns for different models. Accuracy of the conclusions drawn by the expert system has been verified with literature data. Programs for the structural characterization of mixed-layer minerals must allow a) modification of the structural characteristics, abundances, and order-disorder distribution of the layers; b) modification of the distribution of the sizes of coherent scattering domains; and c) consideration of mixed-layer clays with more than two components. Two programs were written to calculate the XRD patterns of two- and three-component mixed-layer minerals consisting of any layer type and without any limitation in the order-disorder relationships.