A copper alloy for electronic or electric devices, comprising: 100 mass ppm or greater and 400 mass ppm or less of Mg; 5 mass ppm or greater and 20 mass ppm or less of Ag; and less than 5 mass ppm of P, with a balance being Cu and inevitable impurities, characterized in that a surface orthogonal to a rolling width direction is used as an observation surface, measurement regarding a matrix is performed on a measurement area of 10000 μm 2 or greater at every measurement intervals of 0.25 μm by an EBSD method, measured results are analyzed by data analysis software OIM to obtain a CI value in each measurement point, a measurement point in which a CI value is 0.1 or less is removed, an orientation difference between crystal grains is analyzed, a boundary having 15° or more of an orientation difference between neighboring measuring points is assigned as a grain boundary, an average grain size A is acquired according to Area Fraction, measurement regarding the matrix is performed at every measurement intervals which are 1/10 or less of the average grain size A by the EBSD method, measured results are analyzed by the data analysis software OIM with a measurement area of 10000 μm 2 or greater in a plurality of visual fields such that a total of 1000 or more crystal grains are included to obtain a CI value in each measurement point, a measurement point in which a CI value is 0.1 or less is removed, an orientation difference between crystal grains is analyzed, and a boundary having 15° or more of an orientation difference between neighboring measuring points is assigned as a grain boundary, a coincidence boundary with Σ29 or less is defined as a special grain boundary, and the other grain boundaries are defined as random grain boundaries, in grain boundary triple junctions analyzed by the OIM, when a ratio of J3, in which all three grain boundaries constituting a grain boundary triple junction are special grain boundaries, to all grain boundary triple junctions is defined as NF J3 and a ratio of J2, in which two grain boundaries constituting a grain boundary triple junction are special grain boundaries and one grain boundary constituting the grain boundary triple junction is a random grain boundary, to all grain boundary triple junctions is defined as NF J2, an expression of 0.22 < (NF J2 /(1-NF J3)) 0.5 ≤ 0.45 is satisfied, and the ratios NF J2 and NF J3 are determined in accordance with the description. 100 mass ppm or greater and 400 mass ppm or less of Mg; 5 mass ppm or greater and 20 mass ppm or less of Ag; and less than 5 mass ppm of P, with a balance being Cu and inevitable impurities, characterized in that a surface orthogonal to a rolling width direction is used as an observation surface, measurement regarding a matrix is performed on a measurement area of 10000 μm 2 or greater at every measurement intervals of 0.25 μm by an EBSD method, measured results are analyzed by data analysis software OIM to obtain a CI value in each measurement point, a measurement point in which a CI value is 0.1 or less is removed, an orientation difference between crystal grains is analyzed, a boundary having 15° or more of an orientation difference between neighboring measuring points is assigned as a grain boundary, an average grain size A is acquired according to Area Fraction, measurement regarding the matrix is performed at every measurement intervals which are 1/10 or less of the average grain size A by the EBSD method, measured results are analyzed by the data analysis software OIM with a measurement area of 10000 μm 2 or greater in a plurality of visual fields such that a total of 1000 or more crystal grains are included to obtain a CI value in each measurement point, a measurement point in which a CI value is 0.1 or less is removed, an orientation difference between crystal grains is analyzed, and a boundary having 15° or more of an orientation difference between neighboring measuring points is assigned as a grain boundary, a coincidence boundary with Σ29 or less is defined as a special grain boundary, and the other grain boundaries are defined as random grain boundaries, in grain boundary triple junctions analyzed by the OIM, when a ratio of J3, in which all three grain boundaries constituting a grain boundary triple junction are special grain boundaries, to all grain boundary triple junctions is defined as NF J3 and a ratio of J2, in which two grain boundaries constituting a grain boundary triple junction are special grain boundaries and one grain boundary constituting the grain boundary triple junction is a random grain boundary, to all grain boundary triple junctions is defined as NF J2, an expression of 0.22 < (NF J2 /(1-NF J3)) 0.5 ≤ 0.45 is satisfied, and the ratios NF J2 and NF J3 are determined in accordance with the description.