Extract country border from OpenStreetMap

There is a service that allows you to retrieve any administrative border from OpenStreetMap in a number of formats. https://osm.wno-edv-service.de/boundaries/


If you want to convert it to a Shapefile just download the xml (for example right-mouse-click on the download link and choose something like "save target as..." instead of opening it in the browser. then in Qgis choose "add vectorlayer" or use drag and drop to add your xml layer to your Qgis project. then save layer as shapefile. If you are just looking for the borders and it does not have to be OSM you could also have a look at http://gadm.org


If you wish to retrieve the OSM Raw XML, that is how Overpass API query would look like:

http://www.overpass-api.de/api/interpreter?data=[bbox];(way[admin_level="2"];way[border_type="nation"];);(._;>;);out body qt;&bbox=112.5,31.9521,123.75,40.9798

Please replace that &bbox=112.5,31.9521,123.75,40.9798 with coordinates of the region of your interest.